|
|
|

|

|
Dicas
|

|
Visual Basic.Net (Datas/Números/Strings)
|
|
 |
Título da Dica: Deixa somente ser digitado números em um TextBox
|
 |
|
|
Postada em 12/1/2006 por ®ogerVB
'Crie a função em um módulo: Public Function SoNumeros(ByVal intAscii As Integer, ByRef oControle As TextBox) As Integer Dim i As Integer
'SO DEIXA SER DIGITADA A CADEIA DE CARACTERES : "0123456789.," If InStr("0123456789.,", Chr(intAscii)) = 0 And intAscii <> 8 Then Return 0 Exit Function End If
'TROCA O PONTO POR VÍRGULA If intAscii = 46 Then intAscii = 44 End If
'NÃO PERMITE A DIGITAÇÃO DE VÁRIAS VÍRGULAS For i = 1 To oControle.TextLength If Mid(oControle.Text, i, 1) = Chr(intAscii) And intAscii = 44 Then Return 0 Exit Function End If Next i Return intAscii End Function
'Para chamar a função, coloque isso no KeyPress do TextBox Dim KeyAscii As Int32 KeyAscii = Asc(e.KeyChar) e.KeyChar = Chr(SoNumeros(KeyAscii, TextBox?))
|
|
|
|

|