C
confused_newbie
I have a variety of comboboxes on a form. I created a hashtable where the
key is the combobox number ("01", "02", "03"..."12") and the value is the
corresponding combobox (cmb01, cmb02, etc)
now I want to allow the user to click a button (cmbSubmit) and have the
program cycle through the comboboxes, grab the text of each, and appended it
to a text file. I've figured out the appending part, but I can't figure out
how to get the text for each box. For example:
=====================
Dim myEnumerator as IDictionaryEnumerator = myHT2.getEnumerator
Dim tempControl as ComboBox
While myEnumerator.MoveNext
tempControl = myEnumerator.value '<-- option strict on disallows
conversion from system.object to system.windows.forms.combobox
MyTextString = MyTextString & ", " & tempControl.text
Next
'then I append the line to my text file
=====================
My alternative is to use:
-------------------------------
for each tempControl in me.controls
MyTextString = MyTextString & ", " & tempControl.text
Next
-------------------------------
but with the first solution, I can add some code that will make sure the
text is collected from the comboboxes in order (rather than the default
order in the hashtable). In this second solution, I don't think (?) I have
any control over the order, although I'd presume that it would grab the
comboboxes/text in the same order each time?
Any help or suggestions appreciated!!
Keith
key is the combobox number ("01", "02", "03"..."12") and the value is the
corresponding combobox (cmb01, cmb02, etc)
now I want to allow the user to click a button (cmbSubmit) and have the
program cycle through the comboboxes, grab the text of each, and appended it
to a text file. I've figured out the appending part, but I can't figure out
how to get the text for each box. For example:
=====================
Dim myEnumerator as IDictionaryEnumerator = myHT2.getEnumerator
Dim tempControl as ComboBox
While myEnumerator.MoveNext
tempControl = myEnumerator.value '<-- option strict on disallows
conversion from system.object to system.windows.forms.combobox
MyTextString = MyTextString & ", " & tempControl.text
Next
'then I append the line to my text file
=====================
My alternative is to use:
-------------------------------
for each tempControl in me.controls
MyTextString = MyTextString & ", " & tempControl.text
Next
-------------------------------
but with the first solution, I can add some code that will make sure the
text is collected from the comboboxes in order (rather than the default
order in the hashtable). In this second solution, I don't think (?) I have
any control over the order, although I'd presume that it would grab the
comboboxes/text in the same order each time?
Any help or suggestions appreciated!!
Keith