1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Visual Basic - Need a quick help

Discussion in 'Programming' started by Dreads, Oct 17, 2008.

  1. #1
    Visual Basic - Need a quick help

    I need a sub that can read a text file line by line System.IO.
    But i want it to delay a bit

    OR If you can fix my script so it would work right
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim FILE_NAME As String = TextBox2.Text
            Dim TextLine As String
            If System.IO.File.Exists(FILE_NAME) = True Then
                Dim objReader As New System.IO.StreamReader(FILE_NAME)
                Do While objReader.Peek() >< -1
                    TextLine = objReader.ReadLine()
                    TextBox1.Text = TextLine
                    ' i need it to sleep 5 seconds
                Loop
    
            Else
                MsgBox("error")
    
            End If
        End Sub
    
    
    Code (markup):

     
    Dreads, Oct 17, 2008 IP
  2. jgarrison

    jgarrison Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can make a 5 second delay with this line:
    system.threading.thread.sleep(5000)

    Also I think Do While objReader.Peek() >< -1 should be Do While objReader.Peek() <> -1

    -Jim
     
    jgarrison, Oct 17, 2008 IP
  3. Dreads

    Dreads Well-Known Member

    Messages:
    1,884
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    150
    #3
    hold up it was like that

    i want to make it so that

    it picks 1 line and then waits 5 seconds and then goes to line 2.
     
    Dreads, Oct 17, 2008 IP
  4. jgarrison

    jgarrison Peon

    Messages:
    66
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Did you try this?

    Do While objReader.Peek() <> -1
    TextLine = objReader.ReadLine()
    TextBox1.Text = TextLine
    ' stop for 5 seconds
    System.Threading.Thread.Sleep(5000)
    Loop

    -Jim
     
    jgarrison, Oct 18, 2008 IP