Validation of Textbox in Visual Basic 6

Asked

Viewed 120 times

1

How do I validate the textbox to enable or disable a button? That’s the code I’ve made so far.

   If IsNumeric(txtPedidoCotacao.text) Then
        cmdMontaPedido.enabled = True
        cmdCancelar.enabled = True
        CmdAutorizacao.enabled = True
        cmdConfiguraPaginas.enabled = True
        cmdCotacoes.enabled = True

        ElseIf KeyAscii = 8 Then
        cmdMontaPedido.enabled = False
        cmdCancelar.enabled = False
        CmdAutorizacao.enabled = False
        cmdConfiguraPaginas.enabled = False
        cmdCotacoes.enabled = False

NOTE: The method is in Keypress ( txtPedidoCotacao_KeyPress ).

1 answer

1

Test this way with the method txtPedidoCotacao_Change():

 Private Sub txtPedidoCotacao_Change()
        If IsNumeric(txtPedidoCotacao) Then
            cmdMontaPedido.Enabled = True
        Else
            cmdMontaPedido.Enabled = False
        End If
    End Sub

Browser other questions tagged

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