cs_Exploreur
Messages postés4821Date d'inscriptionlundi 11 novembre 2002StatutMembreDernière intervention15 novembre 201615 3 févr. 2009 à 22:46
Salut,
Faudrait un peu regarder ce QUE fait le code que je te donne quand même ^^ .... 2 lignes à enlever....
Private Sub Form_Load()
Dim YouString As String
Dim NextString As String
Dim iBoucle As Integer
Dim iNbrChiffre As Integer
Dim iNbrChar As Integer
YouString = "Tata123titi"
For i = 1 To Len(YouString)
NextString = Mid(YouString, i, 1)
If IsNumeric(NextString) Then
iNbrChiffre = iNbrChiffre + 1
Else
iNbrChar = iNbrChar + 1
End If
' ...
Next i
MsgBox "Nombres de numériques : " & iNbrChiffre
MsgBox "Nombres de caractères : " & iNbrChar
End Sub
Ps : Pense à valider quand une réponse résous ton problème
cs_Exploreur
Messages postés4821Date d'inscriptionlundi 11 novembre 2002StatutMembreDernière intervention15 novembre 201615 30 janv. 2009 à 15:08
Re,
Private Sub Form_Load()
Dim YouString As String
Dim NextString As String
Dim iBoucle As Integer
Dim iNbrChiffre As Integer
Dim iNbrChar As Integer
YouString = "Tata123titi"
For i = 1 To Len(YouString)
NextString = Mid(YouString, i, 1)
If IsNumeric(NextString) Then
MsgBox "Numérique trouvé !!": iNbrChiffre = iNbrChiffre + 1
Else
MsgBox "Carractère trouvé !!": iNbrChar = iNbrChar + 1
End If
' ...
Next i
MsgBox "Nombres de numériques : " & iNbrChiffre
MsgBox "Nombres de carractères : " & iNbrChar
End Sub
Vla...c'est çà que tu souhaitais ? Tu peux faire une variante et reconstituer le numérique et la chaine de carractère aussi
cs_domxaline
Messages postés327Date d'inscriptionjeudi 21 août 2008StatutMembreDernière intervention10 mai 20122 3 févr. 2009 à 17:29
merci pour le prg
je l'ai essayé
le prg que tu m'a donné
donne un message chaque fois quand 'il rencontre un charcter ou un chiffre
moi je veux qu'il donne un message pour charcater et un message pour le chiffre
par ex :
6 charcater trouvé
et un autre pour chiffre
3 chiffres trouvés
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
Dim SomeString As String = "George123"
Dim Ascii As Int16
For Each c As Char In SomeString
'MessageBox.Show(c.ToString)
Ascii = Convert.ToInt16(c)
If Ascii > 47 AndAlso Ascii < 58 Then
MessageBox.Show("Contient un chiffre")
Exit For
End If
Next c
End Sub
<!-- Coloration syntaxique vb/vba/vb.net : http://charles.racaud.free.fr/code-syntaxing/ -->
Coloration syntaxique vb/vba/vb.net