Option Explicit
Sub somme()
Dim c As Long, s As Long, i As Long
c = 2: s = 0
For i = c To 99 Step 3
s = s + i
MsgBox "(" & s & " , " & i & ")"
Next i
MsgBox "La somme est :" & s
End Sub
Sub Palindrome()
Dim s As String
s = LCase(Trim(InputBox("Entrer un texte :")))
If s = "" Then Exit Sub
If s = StrReverse(s) Then MsgBox "Le texte " & s & " est un palindrome." Else MsgBox "Le texte " & s & " n'est un palindrome."
End Sub
Public Sub Test_Per(Tableau)
Dim PairS As Long, Impairs As Long, x
For Each x In Tableau
If x = -1 Then Exit For
If x Mod 2 = 0 Then PairS = PairS + 1 Else Impairs = Impairs + 1
Next x
MsgBox "Il y a " & PairS & " nombres pairs (" & Format(PairS / (PairS + Impairs), ".0%") & ")" & vbLf & _
"Il y a " & Impairs & " nombres impairs (" & Format(Impairs / (PairS + Impairs), ".0%") & ")"
End Sub
Sub test_function()
Dim T
T = Array(1, 8, 20, 50, 51, 47, 6, -6, -7, 9, 3, -1)
Test_Per T
End Sub