Loop through empty textbox until the textbox has data

后端 未结 2 2011
南旧
南旧 2021-01-29 15:14

I\'m sure there\'s a simple solution on this, but it escapes me. I have a form with three text boxes on it. Before the main code is run I want to make sure each text box has dat

2条回答
  •  抹茶落季
    2021-01-29 15:33

    I moved my evaluating condition to the execute buttons on click event. There I run an if statement and when hasData is true run the function with the rest of the code.

        Private Sub btnExecute_Click(sender As Object, e As EventArgs) Handles btnExecute.Click
        Dim hasData As Boolean = False
        If txtTechManName.Text.Trim = "" Or txtDirectory.Text.Trim = "" Or txtBxUnique.Text.Trim = "" Then
            hasData = False
            MsgBox(" Please fill all text boxes on form ")
    
            If txtTechManName.Text.Trim = "" Then
                txtTechManName.Focus()
            ElseIf txtDirectory.Text.Trim = "" Then
                txtDirectory.Focus()
            ElseIf txtBxUnique.Text.Trim = "" Then
                txtBxUnique.Focus()
            End If
        Else
            hasData = True
            runProgram()
        End If
    End Sub
    

提交回复
热议问题