VB - SETFOCUS - Focus on textbox after failed validation

0

Hello I'm trying to use the SetFocus function but when I do debug it gives error. So, depending on the validation of if and else in certain cases a msgbox appears that alerts the error and the user when closing it, I wanted to automatically select the box where the error is.

ElseIf txtFind.Text = "" Then
            validacao = validacao + False
            MsgBox("Please fill the XX!", MsgBoxStyle.Critical, "ERRO")
 txtFind.Text.SetFocus

In short, if the field is empty the user receives an error and I want to forward it soon to the missing field. Thanks

    
asked by anonymous 24.08.2016 / 12:20

1 answer

0

Try only txtFind.SetFocus

If txtFind.Text = "" Then
    validacao = validacao + False
    Call MsgBox("Please fill the XX!", vbCritical, "ERRO")
    txtFind.SetFocus
End If
    
31.08.2016 / 21:30