DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    1

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    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

  1. Text Search within Word and Acrobat Files
    By neerajks in forum .NET
    Replies: 0
    Last Post: 04-26-2006, 06:19 AM
  2. text files
    By Spumbu1977 in forum VB Classic
    Replies: 3
    Last Post: 12-24-2005, 01:45 PM
  3. Replies: 1
    Last Post: 03-09-2001, 08:49 AM
  4. Generating multiple text files.
    By frewini in forum XML
    Replies: 0
    Last Post: 01-05-2001, 01:21 PM
  5. Can the ADO Text Driver Update Text Files?
    By Larry Rebich in forum VB Classic
    Replies: 1
    Last Post: 12-15-2000, 10:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links