Support Forums
Listbox Help - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: Listbox Help (/showthread.php?tid=5207)



Listbox Help - Danny - 03-08-2010

I am making a password-storage application on Visual Basic (2008). I need to know how, when you add a list item (which I already know how to do), to also specify a password to go with it. Then when you select it on the listbox it displays the password.

Thanks!!


RE: Listbox Help - thanasis2028 - 03-09-2010

You can use an array to store the passwords and then find the password for the selected item like this: (password() is the array)
Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
     msgbox(password(listbox1.selectedindex))  
End Sub



RE: Listbox Help - Danny - 03-09-2010

"Password is not declared"...

? I only have intermediate experiance with VB... what is "password"? Should I add a textbox named password or something?


RE: Listbox Help - thanasis2028 - 03-09-2010

You should add an array named password. You can do that by writing:
Code:
Public password() as string
This code must be added just after Public Class Form1 and not in any sub or event handler because it needs to be accessible by the whole application.


RE: Listbox Help - Danny - 03-09-2010

Alright now there are no errors but how does the user specify the password they want to go with each listbox item?

Edit: actually now when I run it and select an item off the list it crashes...


RE: Listbox Help - thanasis2028 - 03-09-2010

You can add to the window two textboxes and name them (tb_name,tb_password) and then also add a button that says add password.
I the click event of the button add:
Code:
Listbox1.items.add(tb_name.text) 'adds the name to the list box
password.add(tb_password.text) 'adds the password
also you should change the password declaration code to:
Code:
Public password as new list(of String)



RE: Listbox Help - Danny - 03-10-2010

Thanks so much! It works now.


RE: Listbox Help - Danny - 03-10-2010

Oh wait now I have one problem... I can't use the My.Settings feature to allow users to save it when they open the application next time. How do I do this?


RE: Listbox Help - RaZoR03 - 04-18-2010

(03-09-2010, 11:02 PM)thanasis2028 Wrote: You can add to the window two textboxes and name them (tb_name,tb_password) and then also add a button that says add password.
I the click event of the button add:
Code:
Listbox1.items.add(tb_name.text) 'adds the name to the list box
password.add(tb_password.text) 'adds the password
also you should change the password declaration code to:
Code:
Public password as new list(of String)

ThanksBlackhat