how to hold value from previous form?

izza_azhar

Member
Joined
Mar 1, 2006
Messages
17
Programming Experience
Beginner
hye all,
i already populated value to listbox in form1 then go to next form for some operation.
when i go back to form1, the llistbox are cleared..
i dont know how hold the value .
anyone can answer me??
 
The values in a form don't change unless you or the user change them. They don't just diappera spontaneously. I would guess that you are going back to a different instance of the form. I suggest that you read the first link in my signature to get an understanding of forms as objects. Note that it is a three part article so make sure you read all three parts.
 
Public variable in a module to save the selected index value.

VB.NET:
Expand Collapse Copy
Public listboxsaved As Integer
save the selected index before loading the new form, and reset to the saved index when you come back (close the 2nd form).

VB.NET:
Expand Collapse Copy
        listboxsaved = ListBox1.SelectedIndex
        'call your other form here
        ListBox1.SelectedIndex = listboxsaved
 
Back
Top