I've got an already written VB6 app that I'm trying to make Unicode aware and I'm slowly, but surely, converting everything over to the new combo-box control. I've got it partially working and actually displaying some unicode entries, but I'm getting an error that I can't figure out.
I need to get the Index of whatever item happens to be selected in the ComboBox.
In the _SelectionChanged event which provides a newSelectedItem IComboBoxItem, I can do a newSelectedItem.Index and get the information I want and this works well.
If, however, I try to get the value from cbCombo1.SelectedItem.Index, I get the error "Object Variable or With Block Variable not set." This is in working code where I simply swapped out a standard MS ComboBox control with your new one and changed the line from cbCombo1.Index to cbCombo1.SelectedItem.Index.
I'm still trying to wrap my head around how the new control works, so I've probably made a simple error somewhere. Any help would be much appreciated.
newbe ComboBox questions
Re: newbe ComboBox questions
One extra piece of information. I suspect this is happening because no item is selected at the time I'm trying to get the index. Unfortunately, I couldn't figure out a way to find out if SelectedItem is valid.
I've written a small function that does the same thing so I'm back to using the controls, but I'd still like to know if there's a better way of getting this to work.
I've written a small function that does the same thing so I'm back to using the controls, but I'd still like to know if there's a better way of getting this to work.
Re: newbe ComboBox questions
If no item is selected, then the SelectedItem property returns Nothing of course. Try something like that:
Code: Select all
If Not (ComboBox1.SelectedItem Is Nothing) Then
' something is selected
End If
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
Boycott DRM! Boycott HDCP!
Re: newbe ComboBox questions
Ah, that did the trick (I was originally doing a compare with NULL, but it didn't work). The workaround I was using was to check the count property to see if it was greater than 0.
In any case, I'll still have to continue to use a function to return the proper values as doing a IF-THEN-ELSE every time I need to work with the Index is a bit messy
Thanks for the quick reply. Now, if only I could have as much success unzipping archive files that have unicode filenames
In any case, I'll still have to continue to use a function to return the proper values as doing a IF-THEN-ELSE every time I need to work with the Index is a bit messy
Thanks for the quick reply. Now, if only I could have as much success unzipping archive files that have unicode filenames