my test code:
Code: Select all
...
Dim cCont As Control
For Each cCont In Me.Controls.Frame1
If TypeName(cCont) = "COMBOBOX" Then
Stop
End If
Next cCont
...
Code: Select all
...
Dim cCont As Control
For Each cCont In Me.Controls.Frame1
If TypeName(cCont) = "COMBOBOX" Then
Stop
End If
Next cCont
...
Code: Select all
Dim cCont As Control
Dim sName As String
For Each cCont In Me.Controls
If cCont.Container Is Me.Frame1 And UCase(TypeName(cCont)) = "COMBOBOX" Then
sName = cCont.Name
Debug.Print sName
End If
Next cCont
WORK FINE!HansV wrote: ↑22 Apr 2021, 17:55How about
Code: Select all
Dim cCont As Control Dim sName As String For Each cCont In Me.Controls If cCont.Container Is Me.Frame1 And UCase(TypeName(cCont)) = "COMBOBOX" Then sName = cCont.Name Debug.Print sName End If Next cCont
HUMMMMM. possible to get also the index of combobox?sal21 wrote: ↑22 Apr 2021, 18:45WORK FINE!HansV wrote: ↑22 Apr 2021, 17:55How about
Code: Select all
Dim cCont As Control Dim sName As String For Each cCont In Me.Controls If cCont.Container Is Me.Frame1 And UCase(TypeName(cCont)) = "COMBOBOX" Then sName = cCont.Name Debug.Print sName End If Next cCont
Code: Select all
Dim cCont As Control
Dim TG As Long
Dim sName As String
For Each cCont In Me.Controls
If cCont.Container Is Me.Frame1 Then
TG = TG + 1
If UCase(TypeName(cCont)) = "COMBOBOX" Then
sName = cCont.Name
Debug.Print sName & ": " & TG
End If
End If
Next cCont
Admit i need to use a sname as combobox object, possible?HansV wrote: ↑22 Apr 2021, 19:24You'll have to test that yourself - I don't have VB6.
If Index doesn't work, you could try
Code: Select all
Dim cCont As Control Dim TG As Long Dim sName As String For Each cCont In Me.Controls If cCont.Container Is Me.Frame1 Then TG = TG + 1 If UCase(TypeName(cCont)) = "COMBOBOX" Then sName = cCont.Name Debug.Print sName & ": " & TG End If Next cCont
Code: Select all
With Me.Controls(sName)
...
End With
Code: Select all
Dim cCont As Control
Dim TG As Long
Dim sName As String
For Each cCont In Me.Controls
If cCont.Container Is Me.Frame1 Then
TG = TG + 1
If UCase(TypeName(cCont)) = "COMBOBOX" Then
sName = cCont.Name
Exit For
End If
End If
Next cCont
...
With cCont
...
End With