killerbest Posted May 26, 2014 at 10:47 AM Report #556964 Posted May 26, 2014 at 10:47 AM 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
bids Posted May 26, 2014 at 02:29 PM Report #556987 Posted May 26, 2014 at 02:29 PM 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?
bioshock Posted May 26, 2014 at 02:47 PM Report #556992 Posted May 26, 2014 at 02:47 PM E que tal fazeres uso da MaskedTextbox?
bids Posted May 27, 2014 at 08:11 AM Report #557070 Posted May 27, 2014 at 08:11 AM 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?
killerbest Posted May 27, 2014 at 02:58 PM Author Report #557138 Posted May 27, 2014 at 02:58 PM ok obrigado vou agora testar
bids Posted May 28, 2014 at 08:24 AM Report #557293 Posted May 28, 2014 at 08:24 AM Claro que tens de alterar o handles Ajude-me?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now