ComboBox

ceaser

Active Member
Licensed User
Help (Again!):sign0085:

The following code is when the user clicks on OptionButton2 to select a Total Station. I have three options: OptionButton1 is for a Engineering Level, OptionButton2 is for a Total Station and OptionButton3 is for a GPS. The idea is that the user can select different surveying instruments that he\she works with.

All the different setting for the different instruments are stored in an array called DF().

When the surveyor selects the settings for the first time, the index of the array will be "0".....DF(0)=0, DF(1)=0, DF(2)=0,etc.

What I then use is ComboboxName.SelectedIndex=DF(0), etc

It works fine but not with the last line in the next sub.

Sub OptionButton2_Click
'SaveData
OptionButton1.Checked=False
OptionButton3.Checked=False
InstMake.clear
InstMake.add ("Manual")
InstMake.add ("Leica")
InstMake.add ("Nikon")
InstMake.add ("Topcon")
InstMake.add ("Geodimeter")
InstMake.add ("Pentax")
InstMake.add ("Sokkia")
InstMake.add ("Trimble")
InstMake.add ("Fujiyama")
InstMake.add ("Precision")
DF(100)=1
InstModel.clear
InstMode.clear
InstMode.add ("Fine")
InstMode.add ("Coarse")
InstTrigger.clear
InstTrigger.add ("Instr")
InstTrigger.add ("PPC")
If DF(3)>0 Then InstMake.SelectedIndex=DF(3)
If DF(4)>0 Then InstModel.SelectedIndex=DF(4)
InstTrigger.SelectedIndex=DF(1)
InstMode.SelectedIndex=DF(15)
InstMode.Left=110 :Label31.Left=8
InstTrigger.Left=110 :Label32.Left=8
' get the instrument models
'CheckInstModel
InstModel.SelectedIndex=DF(4)
End Sub

InstModel will depend on what instrument make is selected, ie. if a Leica is selected, then the different models will be a TC1000, TC300, TC400,TC600...etc.

Now in the routine above DF(4) will be "0" when accessed for the first time, untill it has been changed by the user.

But the program keeps on telling me the value cannot be "0"

Please help.

Thanks
Michael
 

klaus

Expert
Licensed User
Longtime User
Hi Michael,

I suspect that there is nothing in the ComboBox and the program doesn't accept value 0 for SelectedItem becaude there is none.

Where do you fill the InstModel ComboBox ? In the CheckInstModel, it is not active it is a comment in your code ?

Best regards.
 

ceaser

Active Member
Licensed User
Hi Klaus

Danke. It works!! Something else I did wrong was to use the "Click" event on the listbox and not "SelectionChanged". I am still getting mixed up with NSBasic.:sign0188::sign0188:

Thanks
Michael
 
Top