Private Sub CommandButton1_Click() toto = "100011" For i = Len(toto) To 2 Step -1 toto = Replace(toto, String(i, "1"), "1") Next corr IIf(Left(toto, 1) & Right(toto, 1) "11", 1, 0) 'orr = Val(Left(toto, 1)) + Val(Right(toto, 1)) Mod 11 toto = Replace(toto, "0", "") nbgr1 = Len(toto) - corr MsgBox nbgr1 End Sub
Dim group() As String Dim strcheck As String strcheck = "100011" group = strcheck.Split(CChar("1")) counterzero = 0 If group.Length > 2 Then For Each l In group If l.Contains("0") Then counterzero += 1 End If Next If counterzero > 1 Then Return False End If End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim group() As String Dim strcheck As String Dim counterzero As Integer Dim counterun As Integer strcheck = "010011" group = strcheck.Split("1"c) counterzero = 0 If group.Length > 2 Then For Each l In group If l.Contains("0") Then counterzero += 1 End If Next If counterzero > 1 Then counterun = 0 group = strcheck.Split("0"c) For Each l In group If l.Contains("1") Then counterun += 1 End If Next If counterun > 1 Then Return False End If End If End If
toto = "111010" corr IIf((Left(toto, 1) & Right(toto, 1) "11" And InStr(toto, "0")), 1, 0) For i = Len(toto) To 2 Step -1 toto = Replace(toto, String(i, "1"), "1") Next toto = Replace(toto, "0", "") nbgr1 = Len(toto) - corr MsgBox nbgr1
Private Sub test() Dim toto As String Dim corr As Integer Dim nbgr1 As Integer toto = "101101" For i = Len(toto) To 2 Step -1 toto = toto.Replace(New String("1"c, i), "1") Next corr CInt(IIf(Microsoft.VisualBasic.Left(toto, 1) & Microsoft.VisualBasic.Right(toto, 1) "11", 1, 0)) toto = toto.Replace("0", "") nbgr1 = toto.Length - corr End Sub
toto = "101010" titi = Split(StrConv(toto, vbUnicode), Chr(0)) corr IIf(titi(0) & titi(UBound(titi) - 1) "11", 1, 0) For i = 1 To UBound(titi) - 1 If titi(i - 1) "1" Then titi(i) "0" Next MsgBox Len(Replace(Join(titi, "0"), "0", "")) - corr