0

我正在创建一个自动化程序,但我被计时器困住了。当我启动程序时,它只是说间隔是 0

这是我得到的:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim TextBox1 As String
    Dim URL As String
    Dim Textbox3 As Integer
    Dim i As Integer
    Dim Times As Integer
    Dim Time As Integer
    Dim Textbox2 As Integer
    Dim rampTimer As New Timer
    Dim Tyme As Integer
Restart:
    TextBox1 = URL
    UseProxy(ListBox1.Items.Item(i))
    WebBrowser1.Navigate(URL)
    Tyme = Textbox3 * 1000 * 6
    rampTimer.Interval = Tyme
    rampTimer.Enabled = True
    Time = Times + 1
    If Time = Textbox2 Then
        MsgBox("Done! Made by Laboboy31", "Done")
        GoTo Last
    End If
    Times = Time
    GoTo Restart
Last:
End Sub
4

1 回答 1

4

Taking a bit of a wild guess here, but I suspect your main issue is around this sort of thing

Dim TextBox3 as Integer
    Tyme = Textbox3 * 1000 * 6
    rampTimer.Interval = Tyme

Now I'm guessing you have a textbox on your form, called "textbox3". First rename it to something meaningful Like ClickInterval. and all the other windows components you are going to refer to in the code.

TextBox3 in your routine is the integer you declared with the dim statement. Because its an Integer, it gets initialised to 0, so Tyme = 0 * 1000 * 6, which is 0...

So given you do have a TextBox called TextBox3, that's the component itself. If you want the content then you'd refer to TextBox3.Text.

Last but not least TextBox.Text is a string, so you need to convert it to an integer(and deal with it not being one). so get rid of the dim statement and try

ramptimer.Interval = Convert.ToInt32(textBox3.text) * 1000 * 6

if I'm on the right lines.

于 2013-02-03T03:16:09.743 回答