Validating TextBox in Visual Basic 6

1

How can I make a validation in the textbox to enable or disable a button? That's the code I've done 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 the KeyPress (txtPuedidoCotacao_KeyPress).

    
asked by anonymous 26.03.2015 / 16:13

1 answer

1

Test this way with txtPedidoCotacao_Change() method:

 Private Sub txtPedidoCotacao_Change()
        If IsNumeric(txtPedidoCotacao) Then
            cmdMontaPedido.Enabled = True
        Else
            cmdMontaPedido.Enabled = False
        End If
    End Sub
    
26.03.2015 / 19:24