user2422403
user2422403

Reputation: 5

How do I get a loop if elseif is true?

I created an app that will browse through my favorite game's pages to find an online person by reading the html code on their profile page. However I am having trouble coming up with a way for it to loop back if it finds "UserOfflineMessage". I inserted ((((Location I want it to loop back)))) where I wanted it to loop back. Any suggestions? BTW: This is not for malicious purposes, this is just a project a few of us were working on.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim Rlo As New IO.StreamReader(My.Resources.Preferences & "Preferences.txt")

    Dim firstLine As String
    'read first line
    firstLine = Rlo.ReadLine()
    'read secondline
    TheText.Text = Rlo.ReadLine()
    'read third line
    Dim thirdLine As String = Rlo.ReadLine()

    Dim Ro As New IO.StreamReader(My.Resources.Preferences & "sig.txt")

    Dim first1Line As String
    'read first line
    first1Line = Ro.ReadLine()
    'read secondline
    The2Text.Text = Ro.ReadLine()

((((Location I want it to loop back))))

    rndnumber = New Random
    number = rndnumber.Next(firstLine, TheText.Text)
    TextBox2.Text = ("http://www.roblox.com/User.aspx?ID=" & number.ToString)
    WebBrowser2.Navigate(TextBox2.Text)
    If WebBrowser2.DocumentText.Contains("[ Offline ]</span>") Then
        check1 = 1
        TextBox1.Text = ("http://www.roblox.com/My/NewMessage.aspx?recipientID=" & number.ToString)
        WebBrowser1.Navigate(TextBox1.Text)
        MsgBox(":R")
    ElseIf WebBrowser1.DocumentText.Contains("UserOfflineMessage") Then
        MsgBox(":D")

    End If
End Sub

Upvotes: 0

Views: 91

Answers (2)

matzone
matzone

Reputation: 5719

Change your ((((Location I want it to loop back)))) with

BackHere :

And add here

ElseIf WebBrowser1.DocumentText.Contains("UserOfflineMessage") Then
    MsgBox(":D")
    Goto BackHere

Upvotes: 0

Markku K.
Markku K.

Reputation: 3908

You could use a Do...While loop:

Dim tryAgain as Boolean
...
Do
    '...your stuff here...
    tryAgain = False
    if BlahBlah Then
        ...
    ElseIf CaseWhereYouWantToLoop Then
        tryAgain = True
    End If
Loop While tryAgain

Upvotes: 2

Related Questions