condition (if) sur un textebox
Bonsoir
je vous demande de l'aide pour comprendre ce que je n'arrive pas à comprendre.
Code:
1 2 3 4 5
| Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If IsNumeric(Me.TextBox1.Text) = False Then
Me.TextBox1.Text = "tata" ' N° 1
Me.TextBox1.Text = "tata" ' N° 2
End If |
quand je tape par exemple 'm' le combobox affiche bien 'tata', s'agit-il de tata N° 1 ou N°2 ?
Merci
(ce n'est que le début de mon problème)
Une autre exemple pour comprendre
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = Nothing
Init_point()
End Sub
Private Sub Init_point() ' Force la culture à autoriser le point pour les décimales
Dim oldDecimalSeparator As String = Application.CurrentCulture.NumberFormat.NumberDecimalSeparator
If Not oldDecimalSeparator = "." Then ' Si se n'est pas un point
Dim forceDotCulture As Globalization.CultureInfo
forceDotCulture = CType(Application.CurrentCulture.Clone(), Globalization.CultureInfo)
forceDotCulture.NumberFormat.NumberDecimalSeparator = "."
Application.CurrentCulture = forceDotCulture
End If
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If TextBox1.Text = Nothing Then Label1.Text = Nothing : Exit Sub
If IsNumeric(TextBox1.Text) = False Then
Label1.Text = "Non numérique : tata N° 1"
Else
TextBox1.Text = Replace(TextBox1.Text, " ", "") ' 'Remplace les espaces par rien.
TextBox1.Select(TextBox1.Text.Length, 0) ' Position du curseur en fin de chaine ' TextBox1.Select(0, 0) ' Position du curseur en début de chaine
Label1.Text = "Numérique : tata N° 2"
End If
End Sub
End Class |