cs_andres06
Messages postés20Date d'inscriptionmardi 6 février 2007StatutMembreDernière intervention12 juin 2007
-
26 mai 2007 à 05:50
cs_andres06
Messages postés20Date d'inscriptionmardi 6 février 2007StatutMembreDernière intervention12 juin 2007
-
27 mai 2007 à 04:01
salut....j ai un probléme en vb 2005...Dans une zone d texte, j veux que quand j écris un virgule ,cette dernière doit être convertie en point.
j ai déjà fait ça en vb6 et voici le code
Private Sub Textbox2_KeyPress(KeyAscii As Integer)If KeyAscii 44 Or KeyAscii 46 Then
If InStr(Textbox2, ",") > 1 Then KeyAscii = 0: Exit Sub
KeyAscii = 44
End If
If KeyAscii <> 8 And KeyAscii <> 44 Then
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End If
End Sub
J veux réécrire ce code en vb2005 ...J espere que vous puissiez m aider.....merci
ptit_tof57
Messages postés79Date d'inscriptionlundi 28 août 2006StatutMembreDernière intervention 4 avril 20091 26 mai 2007 à 07:26
Pardon voici une procédure complete en VB2005 qui contient une textbox et un bouton.
Lorsque tu cliques sur le bouton, la chaine de caractère inscrite dans la textbox est modifié pour remplacé
toutes les virgules par des points comme tu le souhaité.
Private Sub test()
Dim Str As String
Str = TextBox2.Text.Replace(",", ".")
TextBox2.Text = Str
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
test()
End Sub
cs_casy
Messages postés7741Date d'inscriptionmercredi 1 septembre 2004StatutMembreDernière intervention24 septembre 201440 26 mai 2007 à 10:26
La conversion de ton code VB6 en VB2005, devrait te donner quelque chose comme ceci :
Private Sub Textbox2_KeyPress(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox2.KeyPress
If e.KeyChar = Convert.ToChar(44) Or
e.KeyChar = Convert.ToChar(46) Then
If TextBox2.Text.IndexOf(","c) > 0 Then e.KeyChar = Convert.ToChar(0) : Exit
Sub
e.KeyChar = Convert.ToChar(44)
End If
If e.KeyChar <> Convert.ToChar(8) And
e.KeyChar <> Convert.ToChar(44) Then
If e.KeyChar < Convert.ToChar(48) Or
e.KeyChar > Convert.ToChar(57) Then
e.KeyChar = Convert.ToChar(0)
End If
End Sub
---- Sevyc64 (alias Casy) ---- # LE PARTAGE EST NOTRE FORCE #
Vous n’avez pas trouvé la réponse que vous recherchez ?