Jump to content

Recommended Posts

Posted

Boas

Eu tenho um problema que é o seguinte:

Eu preciso que numa textbox, o utilizador só pode inserir numeros, noutra só letras, noutra tipo: o utilizador mete isto na textbox = 41,7777777 e eu quero que ele não possa inserir mais de 7 casas décimais, se alguem me poder ajudar.

Obrigado

Killer

Posted

Eu tenho código que impede o uso de caracteres ou números .

Só que estou um.pouco ausente na área de programação.

Assim que chegar em casa se eu lembrar de passar por cá te envio os códigos.

Ajude-me?

Posted

Este aceita apenas letras

Public Function SomenteCaracteres(ByVal key As String) As Boolean
    'função para digitar só caracteres
'Apenas letras

    If (key >= 65 And key <= 90) Or (key >= 97 And key <= 122) Or key = 8 Or key = 32 Then
	    SomenteCaracteres = False
    Else
	    SomenteCaracteres = True
	    MsgBox("Digite apenas caracteres alfabéticos.", MsgBoxStyle.Information, "Informação de caracteres")
    End If
   End Function

   Private Sub Txtname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtname.KeyPress
    e.Handled = SomenteCaracteres(Asc(e.KeyChar))
   End Sub

Ler apenas numeros

'Este lê apenas numeros
Public Function SomenteCaracteres(ByVal key As String) As Boolean
    'função para digitar só caracteres

    If (key >= 49 And key <= 58) Or key = 48 Then
	    SomenteCaracteres = False
    Else
	    SomenteCaracteres = True
	    MsgBox("Digite apenas caracteres alfabéticos.", MsgBoxStyle.Information, "Informação de caracteres")
    End If
   End Function

   Private Sub Txtname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtname.KeyPress
    e.Handled = SomenteCaracteres(Asc(e.KeyChar))
   End Sub

Ajude-me?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.