VB - SETFOCUS - Focus a textbox after failed validation

Asked

Viewed 94 times

0

Hello I’m trying to use the Setfocus function but when I debug it gives error. Therefore, depending on if and Else validation in certain cases there is an msgbox that alerts to the error and 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 to the missing field. Thank you

  • Exactly what davidterra answered, you cannot set the focus to the Textbox property.

1 answer

0

Just try txtFind.Setfocus

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.