If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Randomized Results from multiple text files

I am having a problem. I know my code may be a bit clunky but here's what I am trying to do: I want to take a random value from a text file and have it displayed in a text window. There are 8 check boxes, each that will be associated with its' own text file. I have not even gotten into the randomization which I am not sure how to do in the first place but I can't figure out how to append entries from multiple checkboxes. Can someone help? And possibly point me in the right direction to take a random line from a text file?

Private Sub Command3_Click()

If Check1 Then ' Each of these statements sets variables to be written into the text window
Open "doors.txt" For Input As #1 'Opens a File
Do Until EOF(1) 'Reads data until the END OF FILE
Line Input #1, NewLine 'Sets input for the NewLine Variable
Text8.Text = Text8.Text + NewLine + NewLine1 + vbCrLf
Loop 'Makes the EOF loop
Close #1 'Closes the file to allow constant use
Exit Sub
End If

If Check2 Then
Open "doors.txt" For Input As #2 'Opens a File
Do Until EOF(2) 'Reads data until the END OF FILE
Line Input #2, NewLine1 'Sets input for the NewLine Variable
Text8.Text = Text8.Text + NewLine + NewLine1 + vbCrLf
Loop 'Makes the EOF loop
Close #2 'Closes the file to allow constant use
Exit Sub
End If

If Check3 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If

If Check4 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If

If Check5 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If

If Check6 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If

If Check7 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If

If Check8 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If

If Check9 Then
Text8.Text = PickOne("Program", "Debug", "Email", "Write")
End If