Form2 can have a reference to Form1. In Form2 declarations:
Private ReferenceForm1 as Form1
If the data variable in Form1 is declared as Public or Friend, you can get
its value from Form2:
ReferenceForm1.data
If data=5, and the ComboBox or ListBox has the SelectedIndex of 5 for
"Five", or the SelectedValue of "5" for "Five", then when you set that
property, "Five" will be displayed.
In the Form2 Load event:
ComboBox1.SelectedIndex = ReferenceForm1.data
or
ComboBox1.SelectedValue = ReferenceForm1.data
In the first case, data would be numeric, in the second, a string. The
SelectedValue property is determined by the ValueMember property of the
ComboBox. It points to a Fieldname. The DisplayMember property also points
to a FieldName, and defines which column is shown in the ComboBox.
www.charlesfarriersoftware.com
"http://www.visual-basic-data-mining.net/" wrote:
Hi...
Say i have this string call "data" in Form1, this string contains number "5"
value....
how do i pass this string to the Form2 and compare with the combo box
items...
The combo box DropDownStyle is set to DropDownList...
which means when i pass, the SelectedIndex must be subtract or add by 1 to
get the correct items to display...
The Listbox items contain:
One, Two, Three, Four and Five...
How to i actually pass this string to Form2 and Form2 will compare the
number 5 with the items and display Five instead in the combo box
correctly..
Thanks
toytoy -- forum member
http://www.visual-basic-data-mining.net/forum