0

我有以下代码:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    If Not TextBox1.Text = "" Then
        If TextBox1.Text.Contains("ping") Then
            Dim PingSplit = TextBox1.Text.Split(" ")
        End If

        Select Case TextBox1.Text

            Case "ping"
                MsgBox(PingSplit(2).ToString)' debug
                '  If Not Regex.Match(PingSplit(2), "\A(\d{1,2}/(1[0-99]\d)/(2[0-55]\d)).(\d{1,2}/(1[0-99]\d)/(2[0-55]\d)).(\d{1,2}/(1[0-99]\d)/(2[0-55]\d)).(\d{1,2}/(1[0-99]\d)/(2[0-55]\d))\Z").Success Then
                MsgBox("Invalid address!")
                Else
                MsgBox(GetPingMs(PingSplit(2)))
                End If
        End Select

    Else
        MsgBox("System: Please insert a command!")
    End If
End Sub

但是我无法弄清楚如何获取代码以拆分 textbox1 中的文本并将后半部分传递给 GetPingMs 函数,我知道该函数有效,但我无法弄清楚如何传递数据。任何帮助将不胜感激。

4

1 回答 1

0

PingSplit在内部声明If并且在Select.

另外我不明白您尝试在 TextBox1.Text 中选择哪些情况

在 all 之前移动“PingSplit”的声明if,但仍在该函数内:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim PingSplit as String
If Not TextBox1.Text = "" Then
        If TextBox1.Text.Contains("ping") Then
            PingSplit = TextBox1.Text.Split(" ")
        End If

        Select Case TextBox1.Text

            Case "ping"
                MsgBox(PingSplit(1).ToString)' debug

                ' Commented if by question author.
                '  If Not Regex.Match(PingSplit(1), "\A(\d{1,2}/(1[0-99]\d)/(2[0-55]\d)).(\d{1,2}/(1[0-99]\d)/(2[0-55]\d)).(\d{1,2}/(1[0-99]\d)/(2[0-55]\d)).(\d{1,2}/(1[0-99]\d)/(2[0-55]\d))\Z").Success Then
                'MsgBox("Invalid address!")
                'Else
                'MsgBox(GetPingMs(PingSplit(1)))
                'End If
        End Select

    Else
        MsgBox("System: Please insert a command!")
    End If
End Sub
于 2013-10-25T23:14:50.463 回答