|
-
Aug 15th, 2000, 06:47 PM
#1
Thread Starter
Addicted Member
I've got a filelistbox, and I want it to have a certain file selected when the form loads. I know it's probably a newbie question, but how can i do that? =)
I've tried several things, and havent been able to do it. I keep getting runtime errors, whenever I try something.
Any help would be appreciated.
Thanks,
Stephen
-
Aug 15th, 2000, 07:27 PM
#2
Try something like:
Code:
Private Sub Form_Load()
Dim lIndex As Long
For lIndex = 1 To File1.ListCount
If File1.List(lIndex) = "SomeFile.txt" Then
File1.ListIndex = lIndex
Exit For
End If
Next
End Sub
-
Aug 15th, 2000, 07:54 PM
#3
You could also use:
Code:
File1.ListIndex = 0
Or you can randomize it:
Code:
Function randomnumber(finished)
Randomize
randomnumber = Int((Val(finished) * Rnd) + 1)
End Function
Private Sub Command1_Click()
i = randomnumber(File1.ListCount)
File1.ListIndex = i
End Sub
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
|