toto = "toto = "ceciestuntexteimprovisé1264567avecunevaleurnumérique""
Do While Val(toto) = 0
toto = Mid(toto, 2)
Loop
MsgBox Val(toto)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub Command1_Click()
If num_int(Text1.Text) = num_int(Text2.Text) Then
MsgBox "oui"
Else
MsgBox "non"
End If
End Sub
Private Function num_int(chaine As String) As String
num_int = chaine
Do While Val(num_int) = 0
num_int = Mid(num_int, 2)
Loop
num_int = Str(Val(num_int))
End Function
Dim s1 As String = "Le même texte au début 1234, 123456, pas le même texte à la fin" Dim s2 As String = "Le même texte au début 123, 123456; une fin alternative" Dim maRegex As New Regex("\D(\d)+\D") Dim occurcences1 As MatchCollection = maRegex.Matches(s1) Dim occurcences2 As MatchCollection = maRegex.Matches(s2)
Il est en VB6oh j'ai pas fait attention ce matin, réveil un peu dur....
Dim str1 As String
Dim str2 As String
Dim strnum As String
Dim index1 As Integer
Dim p As Integer
Dim indexl As Integer
Dim indexr As Integer
Dim found As Boolean
found = False
str1 = "bnbnvbvbv923456bfbfgfgfg"
str2 = "teerereorfgfgdfd923456tytytryrt"
index1 = 1
'on cherche le premier chiffre
While index1 < Len(str1) And Not found
p = Asc(Mid(str1, index1, 1))
If (p >= 48) And (p <= 57) Then
indexl = index1
found = True
Else
index1 = index1 + 1
End If
Wend
found = False
'on cherche le caractère non chiffre
While index1 < Len(str1) And Not found
p = Asc(Mid(str1, index1, 1))
If (p < 48) Or (p > 57) Then
indexr = index1
found = True
Else
index1 = index1 + 1
End If
Wend
strnum = Mid(str1, indexl, indexr - indexl)
If InStr(str2, strnum) > 0 Then
'
End If
Private Sub CommandButton4_Click()
Dim str1 As String, str2 As String
str1 = "bn102bnvbvbv923456bfbfgfgf1248gh27"
str2 = "teerereorfgfgdfd923456tytytryrt327123hhf"
nums_str1 = Trim(num_int(str1))
nums_str2 = Trim(num_int(str2))
MsgBox nums_str1 & vbCrLf & nums_str2
End Sub
Private Function num_int(chaine As String) As String
Dim tata() As Byte
tata() = StrConv(chaine, vbFromUnicode)
For i = 0 To UBound(tata)
Select Case tata(i)
Case 48 To 57
Case Else
tata(i) = 32
End Select
Next
num_int = Trim(StrConv(tata(), vbUnicode))
End Function