在if语句中满足条件时停止执行其余代码

时间:2015-06-12 08:34:14

标签: vb.net try-catch

如果用户将其留空,我该如何跳转到文本框。我使用的if-else显示消息框但仍然继续代码的其余部分。

这是我的代码:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If TextBox1.Text = "" Then
        MsgBox("enter word to search for")
    End If
    WebBrowser1.Hide()

2 个答案:

答案 0 :(得分:0)

你可以这样做:

fields[0] means, the first declared field, in which 0 is again hard coded

答案 1 :(得分:0)

您需要将Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If TextBox1.Text = "" Then MsgBox("enter word to search for") Else WebBrowser1.Hide() End If 放在else语句中 试试这个:

Exit Sub

或者您可以使用Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If TextBox1.Text = "" Then MsgBox("enter word to search for") Exit Sub End If WebBrowser1.Hide()

ionic.Platform.ready(function() {
    // will execute when device is ready, or immediately if the device is already ready.
    $scope.deviceInformation = ionic.Platform.device();
    $scope.currentPlatform = ionic.Platform.platform();
    $scope.currentPlatformVersion = ionic.Platform.version();
});