Hi,
I have a panel with some controls, namely a combobox.
I want to find the selectedIndex property of the combo.
But I can't seem to work it out.
This is the code I have
Does anyone no what I am doing wrong here?
Thanks
I have a panel with some controls, namely a combobox.
I want to find the selectedIndex property of the combo.
But I can't seem to work it out.
This is the code I have
Code:
Public Function GetSelectedIndex(ByVal pnl As Panel, ByVal ctlName As String) As Integer
Dim ctl As Control
Dim cmb As ComboBox
GetSelectedIndex = 0
For Each ctl In pnl.Controls
cmb = CType(ctl, ComboBox)
If ctlName = ctl.Name Then
GetSelectedIndex = cmb.SelectedIndex
Exit For
End If
Next
End Function
Does anyone no what I am doing wrong here?
Thanks