Private Sub FillFldCtrl(rst408 As ADODB.Recordset, strTimeType408 As String) '循環填入值到控件
Dim ctrl As Object, C99 As Integer
If D = 1 Then
For C99 = 1 To 35
For Each ctrl In Detail.Controls
If TypeName(ctrl) = "Field" Then If ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99) Then
ctrl.Text = Trim(rst.Fields(C99 - 1).Value)
End If
End If
Next
Next C99
End If
End Sub為什麽我的循環是一直在查控件名?並且是每個控件名都循環了35次?
這段代碼是希望通過查到
If TypeName(ctrl) = "Field" Then
If ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99) Then
需要賦值的控件一共有35個:lbl1_1.field 到 lbl1_35.field
然後
ctrl.Text = Trim(rst.Fields(C99 - 1).Value)
賦值進去現在不知道哪里寫錯了?誰告訴我一下!
Dim ctrl As Object, C99 As Integer
If D = 1 Then
For C99 = 1 To 35
For Each ctrl In Detail.Controls
If TypeName(ctrl) = "Field" Then If ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99) Then
ctrl.Text = Trim(rst.Fields(C99 - 1).Value)
End If
End If
Next
Next C99
End If
End Sub為什麽我的循環是一直在查控件名?並且是每個控件名都循環了35次?
這段代碼是希望通過查到
If TypeName(ctrl) = "Field" Then
If ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99) Then
需要賦值的控件一共有35個:lbl1_1.field 到 lbl1_35.field
然後
ctrl.Text = Trim(rst.Fields(C99 - 1).Value)
賦值進去現在不知道哪里寫錯了?誰告訴我一下!
'循環填入值到控件
Dim ctrl As Object, C99 As Integer
If D = 1 Then
For C99 = 1 To 35
For Each ctrl In Detail.Controls
If TypeName(ctrl) = "Field" Then
If ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99) Then
ctrl.Text = Trim(rst.Fields(C99 - 1).Value & vbNullString)
Exit For
End If
End If
Next
Next C99
End If
End Sub
For C99 = 1 To 35
For Each ctrl In Detail.Controls
下面這句我是不是寫錯了,我是想當 D=1時,ctr1=lbl1 第一列頭,
然後跑ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99)=lbll_1.field
到lbl1_35.field 縱向賦值的。
If TypeName(ctrl) = "Field" Then
If ctrl.Name = "lbl" & strTimeType408 & "_" & CStr(C99) Then
循環到這里就跳過去了,一直進行上段的循環,沒有進行賦值
ctrl.Text = Trim(rst.Fields(C99 - 1).Value & vbNullString)
Exit For
End If
End If
Next
Next C99
End If
End Sub
ctrl.Text = Trim(rst.Fields(C99 - 1).Value & vbNullString)
Exit For
End If
Dim C99 As Integer
Dim sCtrlName As String If D = 1 Then
For C99 = 1 To 35
sCtrlName = "lbl" & strTimeType408 & "_" & CStr(C99)
Detail.Controls(sCtrlName).Text = Trim(rst.Fields(C99 - 1).Value)
Next C99
End If
End Sub