04-13-2004, 05:55 PM | #1 (permalink) |
Banned
|
visual basic 6 help
hey guys i need help i just started vb6 and dont know much.
k ths is the prob: i got a list and i have 2 names on the list and on the side i have a text box so it can display a message of the program inthe list. for the first program in the list which is cd-mate when i run the program and i click on the the name it shows the info ont he text box. but heres the prob: when i run the prog and lcik ont he 2nd name which is nero then it shows the same info as it showed for cd-mate, so i need you guys to help me and seperate the code so that i can have seperate infos for each program in the list. this si the code that i have in the list box window inorder for the info to come out int he text box. Private Sub List1_Click() Text1.Text = "6.14" End Sub |
04-17-2004, 06:23 AM | #2 (permalink) |
Crazy
Location: Europe
|
Well, you don't say much about what you are trying to accomplish. But this may be one possible way:
if List1.ListIndex = 0 then Text1.Text = "6.14" if List1.ListIndex = 1 then Text1.Text = "5.04" ListIndex gives you the rows in the list. First row = 0 It seems this could be done alot better though, but I guess you are just playing around to learn? This way the software must be listed in the same order every time. If they are not then you must check the value on the row to know what to display in the text box. Like: if List1.Text = "Nero" then Text1.Text = "5.04" Even this might not be so practical since you must hard code your data all over the code. You might want to learn to define a string array of software names and their versions. Then all the data is typed in at one place. Then on load you populate the list with the names from the array, and on click you display the version from the array. Eventually you will find that the only practical way is to have a database. But that is only if you get serious with this application.
__________________
Coffee |
04-17-2004, 12:26 PM | #3 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
Private Sub List1_Click()
select case List1.ListIndex case 0 'do things related to entry 0 case 1 'do things related to entry 1 case 2 'do things related to entry 2 end select End Sub
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
04-21-2004, 11:09 AM | #5 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
*sniffle
select case is better, its modualar and usues less code and processing power. also if you want to get the text from a listbox from its index Code:
Private Sub List1_Click() MsgBox List1.List(List1.ListIndex) End Sub
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen |
Tags |
basic, visual |
|
|