|
-
April 13th, 2001, 11:11 AM
#1
Visual Basic Help
Hi all - I am a programming rookie and am having some trouble with a program. For the program, I'm supposed to read a grocery list from a text file into a listbox. Then, I'm supposed to create another list box. This second list box will be populated by me clicking on items in the first list box and then clicking on a command button that will add all the items I selected. It's supposed to work even if there's more than one item selected. Any help would be greatly appreciated. Thanks.
Archie Kantzavelos
-
April 13th, 2001, 11:23 AM
#2
Re: Visual Basic Help
Do you have a sample of your code? That may help determine why it isn't working.
"There are no stupid questions, but there are a lot of inquisitive idiots."
-
April 13th, 2001, 11:41 AM
#3
Re: Visual Basic Help
Here's the code for you.
private Sub cmdAdd_Click()
Dim i as Integer
for i = 0 to List1.ListCount - 1
If List1.Selected(i) then
List2.AddItem List1.List(i)
End If
next
End Sub
private Sub Form_Load()
Dim aLine as string
Open App.Path & "\grocery.txt" for input as #1
Do While Not EOF(1)
Line input #1, aLine
List1.AddItem aLine
Loop
Close #1
End Sub
-
April 13th, 2001, 01:47 PM
#4
Re: Visual Basic Help
change the line in your code
If List1.Selected(i) then
List2.AddItem List1.List(i)
to the following
If List1.Selected(i) = True Then
List2.AddItem List1.List(i)
Iouri Boutchkine
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|