0

我创建了一个应用程序,它可以浏览我最喜欢的游戏页面,通过阅读他们个人资料页面上的 html 代码来查找在线人。但是,如果它找到“UserOfflineMessage”,我很难想出一种方法让它循环回来。我插入了 ((((Location I want it loop back)))) 我希望它循环回来的地方。有什么建议么?顺便说一句:这不是出于恶意目的,这只是我们几个人正在进行的一个项目。

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()

((((我希望它循环返回的位置))))

    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
4

2 回答 2

2

您可以使用 Do...While 循环:

Dim tryAgain as Boolean
...
Do
    '...your stuff here...
    tryAgain = False
    if BlahBlah Then
        ...
    ElseIf CaseWhereYouWantToLoop Then
        tryAgain = True
    End If
Loop While tryAgain
于 2013-05-27T05:22:08.793 回答
0

改变你((((Location I want it to loop back))))

BackHere :

并在此处添加

ElseIf WebBrowser1.DocumentText.Contains("UserOfflineMessage") Then
    MsgBox(":D")
    Goto BackHere
于 2013-05-27T10:41:49.340 回答