-
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
FileError:
MsgBox "Error Reading Data File."
End Sub
-
I guess you mean append data in a TextBox.
Use the SelText property:
with myTextBox
.selStart = len(.Text)
.selText = newText
"There are two ways to write error-free programs. Only the third one works."
Unknown
Similar Threads
-
By neerajks in forum .NET
Replies: 0
Last Post: 04-26-2006, 06:19 AM
-
By Spumbu1977 in forum VB Classic
Replies: 3
Last Post: 12-24-2005, 01:45 PM
-
Replies: 1
Last Post: 03-09-2001, 08:49 AM
-
Replies: 0
Last Post: 01-05-2001, 01:21 PM
-
By Larry Rebich in forum VB Classic
Replies: 1
Last Post: 12-15-2000, 10:29 AM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|