Storing and retrieving string?

kae

Member
Joined
Aug 4, 2005
Messages
5
Programming Experience
Beginner
RESOLVED: Storing and retrieving string?

Writing program is used to save various keywords

I have a listbox, three textboxes and a button,

textbox1 is for the description of what the pass is for, textbox2 is for the KWs, and the button serves to enter the info. When pressed the description goes into the listbox, that works fine. The third box shows the KWs when the description in the listbox is selected.

What I dont know is how to link the KW and description together so that after enter is pressed and the description goes into the listbox, if I was to select that descripton in the textbox the KW would appear in the third box. Help?
 
Last edited:
You could create a DataTable and bind your data using the DataSource, DisplayMember and ValueMember properties of the ListBox. This would make the selection process almost automatic, but creating the table would be the (slightly) tedious part. The alternative, assuming that your descriptions are unique, would be to use a HashTable. You would add the description and keywords as a key/value pair to the HashTable. Then when the user selects a description from the list you use that key to get the corresponding key word value from the HashTable. You could also just keep the key words in an ArrayList and select the correct entry according to the SelectedIndex of the ListBox.
 
Ok thanks for replying, hope this makes it clearer

1st this is what I'm doing..


----------
I have a listbox.

There are two textboxes for input: "description" and "password"
theres a button ("add") with them so that when it is pressed, the text from "description" goes into the listbox.

Theres a third textbox that only displays stored passwords. The pass only appears when you select an item in the listbox.


So you were to use it, it should work like this,
enter description here - "kulrom's ftp"
enter password here - "thunny"

Click add

Kulrom's Ftp would be now in the listbox.

Now if I clicked Kulrom's Ftp in the listbox then "thunny" should appear in the 3rd textbox that displays the pass.
--------

Now I have the description going into the text box when enter is clicked, but I have no idea how to associate the password with it so that it will be stored and retrieved. Hope this helps, thanks
 
I would create a hashtable in your form.

Dim passwords As new Hashtable

When you click on Add, it does something like:

passwords.Add(txtDesc.Text, txtPwd.Text)

Then, when you click on the item in the list box:
txtShowpwd.Text = password(lstStuff.Selecteditem())

Thats probably not completely right, but hopefully it gives you an idea of how to do it :)
 
tomhosking said:
I would create a hashtable in your form.

Dim passwords As new Hashtable

When you click on Add, it does something like:

passwords.Add(txtDesc.Text, txtPwd.Text)

Then, when you click on the item in the list box:
txtShowpwd.Text = password(lstStuff.Selecteditem())

Thats probably not completely right, but hopefully it gives you an idea of how to do it :)

Thanks, I'll try that. Since jmcilhinney replied with his suggestions I've been trying to figure out exactly how to do them, you just gave me a little more clarity, I'll get back to you guys if I get it right (or if I dont :eek: ).
 
Back
Top