I have a dropbox with a fixed number of items, defined as:
"A --- item 1"
"B --- item 2"
"C --- item 3"
From elsewhere in the program I get a string, containing the first letter of the items. e.g. B
When the form with the dropbox loads, I want to preselect the index with that letter.
I thought about using InStr, but it doesn't seem to work.
Dim TmpStr as String = String.Empty
TmpStr = Str.InStr(0,1)
Select Case TmpStr
cbox.SelectedValue = 0
cbox.SelectedValue = 1
cbox.SelectedValue = 2
To get the character you can use
TmpStr = Str.Substring(0,1) to get a single character in string format or
TmpStr = Str.First() which returns the first letter as a character type.
Then, as mentioned in my comment, inside your select, set the
SelectedIndex property of your Combobox to the respective index.
Note: You also need to change the
End Case to