***** Messages Popup En VBA (Pour Word, Excel,...) *****

PMHello1_vba.HTM PM2x2_vba.HTM
PMHello5_vba.HTM PMCalc_vba.HTM PMChr20_vba.HTM
PMHello9_vba.HTM PMMsg_vba.HTM PMPrime_vba.HTM


Sub PopupHello1() MsgBox ("Hello World...") End Sub Sub PopupHello5() MsgBox ("Hello World....." & vbCrLf _ & "Hello World....." & vbCrLf _ & "Hello World....." & vbCrLf _ & "Hello World....." & vbCrLf _ & "Hello World....." & vbCrLf) End Sub Sub PopupHello9() Dim i Dim MsgHello '----- LOOP , Prepare message MsgHello = "" For i = 1 To 9 MsgHello = MsgHello & "Hello World........." & vbCrLf Next MsgBox (MsgHello) End Sub
Sub Popup2x2() MsgBox (2 + 2) End Sub Sub PopupCalc() Dim R Dim C, A Dim MsgCalc R = 10 C = 2 * 3.14159 * R A = 3.14159 * R * R MsgCalc = "Radius=" & R & vbCrLf _ & "Circumference=" & C & vbCrLf _ & "Area=" & A & vbCrLf MsgBox (MsgCalc) End Sub Sub PopupMsg() Dim MyMsg MyMsg = "- Nice weather, isn't it ?" & vbCrLf _ & "- Yes ""nice"" weather." & vbCrLf MsgBox (MyMsg) End Sub
Sub PopupChr20_FF() Dim i Dim MsgChars MsgChars = "***** CHARS: " '----- LOOP For i = 32 To 255 MsgChars = MsgChars + (Chr(i)) Next MsgBox (MsgChars) End Sub Sub PopupPrimeNb() Dim IsPrimeArray(1000) Dim i Dim j, jMax Dim MsgNumbers MsgNumbers = "***** PRIME NUMBERS: " '----- LOOP 1 , On each number For i = 1 To 1000 '----- Could be a prime number IsPrimeArray(i) = True '----- LOOP 2 , Search a divisor j = 2 jMax = i \ 2 '--- Int div While IsPrimeArray(i) And (j <= jMax) '----- "j" can divide "i" ? If (i Mod j) = 0 Then IsPrimeArray(i) = False End If j = j + 1 Wend '----- Display only prime numbers If IsPrimeArray(i) = True Then MsgNumbers = MsgNumbers & i & " " End If Next i MsgBox (MsgNumbers) ' ' [<-- i -->] ' [<-- j -->] ' .#.....................#.........................# ' | | | ' 2 i div 2 1000 ' End Sub