|
-
Jan 5th, 2010, 11:27 AM
#8
Thread Starter
Fanatic Member
Re: Randomly Selecting Text File Number, Selecting Line, and Retrieving Part of a Lin
I believe I may have the random selecting of the text file numbers down pat, but I am having problems with randomly selecting a line from a range of 7 lines (the line numbers, in this case, would be 3 to 9). Plus from that line, I would like to display in the SetCluePW area the first word on that particular line randomly selected
Here is the code I have thus far:
Code:
Public Sub FirstClue1()
Dim i As Integer, j As Integer, X As Integer, tmpint As Integer
PlaySound App.Path & "\sounds\wordsound.wav", ByVal 0&, SND_ASYNC Or SND_FILENAME
i = Rnd * 7 + 1
For j = 3 To 9
j = i
Line Input #1, tmpstr
tmp = Split(tmpstr, ",")
PWClue1(j) = tmp(0): Guess1(j) = tmp(1)
Next j
' Randomize
For i = 3 To 9
X = Int(Rnd() * 7) + 1
tmpstr = PWClue1(i)
tmpint = Guess1(i)
PWClue1(i) = PWClue1(X)
Guess1(i) = Guess1(X)
PWClue1(X) = tmpstr
Guess1(X) = tmpint
Next
CurrentPW = CurrentPW + 1
If CurrentPW > 8 Then CurrentPW = 1
SetCluePW PWClue1(CurrentPW)
End Sub
When I did a test run on the form, I got a pop-up message saying "Run-time Error '52': Bad file name or number." When I clicked the "Debug" button on the pop-up, it displayed where the error prevails (the line in bold red text). Where did I go wrong?
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
|