Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very novice question on listbox

Status
Not open for further replies.

osorio

MIS
Jul 8, 2001
7
VE
hello.
I am trying to do a very simple database, with a listbox containing a name and phone number. but I am a very novice programmer and have a lot of questions.
a) How do I make the information that is stored in my listbox get stored in my hard drive, so that every time I run the program it has all the information in it? From what I have read in other threads about listboxes, I think that this is done with querys, but I don´t know how to use them very well.
b) How do I take something (the contents of a listbox, for example) from a form and use it in another form?
c) How do I make a listbox contain two columns ( I put columns:2 in the listbox options, but nothing happened) and how can I add two items, one going to column one and the other to column two?
Thank you very much.
 
Hi im not too good but these are my ideas

1- If u just want to get the same details each time from a .txt file or .dat, read the stuff from a file into an array then load each line of the array into the listbox. Or if you want to use a database such as Access then use a Datacombo (i dont know if there is a datalist), and set the datasource to your recordset. A query you might want to use is: "select Distinct Field1 from table1" This will pick each different value in field1 from table1. This is what i have done and i find it useful

2 - Declare a public varialbe in a module then you can use it anywhere in your app if you store the list1.Text into the variable. eg. Public strlistText As String
strlistText = list1.Text

3 - I had trouble with the 2 column combo box myself, and my teacher wasnt much help (I have exams in a week so he better start helping). I did really need it though, im sure someone can help.

Good Luck
The best thing to do is to keep asking questions on forumns like these and the vb newsgroups, they all help
:)
 
The columns property of a list box will determine how many columns of data are displayed. It is still only one list but.
If you want to have two columns, you could place 2 list boxes next to each other and then add appropriate data to each of then.
To take data from one list box to another you could try something like

for i = 0 to form1.list1.listcount - 1
form2.list1.additem form1.list1.list(i)
next i

hope this helps
 
A.
FAQ222-1198 and FAQ222-39 cover how to write to ".INI" files. 1198 provides a class to representing the file while 39 shows how the usage of the API functions directly. You can use one of these to load and save values to files to files on the hard drive.

B.
Reference objects within other objects by indicating their "parentage" The listbox named list1 on form2 is form2.list1. When you need to save values after a form is unloaded, use globals as indicated above.

C.
The multicolumn listbox is an interesting animal. It uses your list object length to determine how many per cpolumn then uses multiple columns to display the list. Often this forces teh list to scroll horizontally, not virtically. Sort of like when you select the list type for a directory in explorer. Other than being from the same list the columns do not have a relationship to each other. Try adding more items to your listbox to see the impact. The columns appear as needed, beyond even the number you specified.

It sounds like the control you're looking for is more along the linbes of the grid control.

Wil Mead
wmead@optonline.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top