Attribute VB_Name = "Module1" Public Sub Summa1_10_virhe1() Dim Lp As Long Dim Summa As Long Lp = 1 Do While Lp < 10 Summa = Summa + Lp Lp = Lp + 1 Loop MsgBox Summa End Sub Public Sub Summa1_10_virhe2() Dim Lp As Long Dim Summa As Long Lp = 1 Do While Lp <= 10 Lp = Lp + 1 Summa = Summa + Lp Loop MsgBox Summa End Sub Public Sub Summa1_10_oikein() Dim Lp As Long Dim Summa As Long Lp = 1 Do While Lp <= 10 Summa = Summa + Lp Lp = Lp + 1 Loop MsgBox Summa End Sub Public Function PutsaaStrDoWhile(ByVal MJono As String) As String Dim OutStr As String Dim LpI As Long Dim LpL As Long OutStr = "" LpI = 1 LpL = Len(MJono) Do While LpI <= LpL If (UCase(Mid(MJono, LpI, 1)) >= "A") And _ (UCase(Mid(MJono, LpI, 1)) <= "Z") Then OutStr = OutStr & Mid(MJono, LpI, 1) End If LpI = LpI + 1 Loop PutsaaStr = OutStr End Function Public Function PutsaaStrWhileWend(ByVal MJono As String) As String Dim OutStr As String Dim LpI As Long Dim LpL As Long OutStr = "" LpI = 1 LpL = Len(MJono) While LpI <= LpL If (UCase(Mid(MJono, LpI, 1)) >= "A") And _ (UCase(Mid(MJono, LpI, 1)) <= "Z") Then OutStr = OutStr & Mid(MJono, LpI, 1) End If LpI = LpI + 1 Wend PutsaaStrWhileWend = OutStr End Function Public Function PutsaaStrDoUntil(ByVal MJono As String) As String Dim OutStr As String Dim LpI As Long Dim LpL As Long OutStr = "" LpI = 1 LpL = Len(MJono) Do Until LpI > LpL If (UCase(Mid(MJono, LpI, 1)) >= "A") And _ (UCase(Mid(MJono, LpI, 1)) <= "Z") Then OutStr = OutStr & Mid(MJono, LpI, 1) End If LpI = LpI + 1 Loop PutsaaStr = OutStr End Function Public Function PutsaaStrForNext(ByVal MJono As String) As String Dim OutStr As String Dim LpI As Long Dim LpL As Long OutStr = "" LpL = Len(MJono) For LpI = 1 To LpL If (UCase(Mid(MJono, LpI, 1)) >= "A") And _ (UCase(Mid(MJono, LpI, 1)) <= "Z") Then OutStr = OutStr & Mid(MJono, LpI, 1) End If Next LpI PutsaaStrForNext = OutStr End Function Public Sub ForNextLoop1() Dim Lp As Long For Lp = 1 To 10 Next Lp MsgBox Lp End Sub Public Sub ForNextLoop2() Dim Lp As Long Dim ParSumma As Long ParSumma = 0 For Lp = 2 To 100 Step 2 ParSumma = ParSumma + Lp Next Lp MsgBox ParSumma End Sub Public Function PutsaaStrLoopDoWhile(ByVal MJono As String) As String Dim OutStr As String Dim LpI As Long Dim LpL As Long OutStr = "" LpI = 1 LpL = Len(MJono) Do If (UCase(Mid(MJono, LpI, 1)) >= "A") And _ (UCase(Mid(MJono, LpI, 1)) <= "Z") Then OutStr = OutStr & Mid(MJono, LpI, 1) End If LpI = LpI + 1 Loop While LpI <= LpL PutsaaStrLoopDoWhile = OutStr End Function Public Function PutsaaStrLoopDoUntil(ByVal MJono As String) As String Dim OutStr As String Dim LpI As Long Dim LpL As Long OutStr = "" LpI = 1 LpL = Len(MJono) Do If (UCase(Mid(MJono, LpI, 1)) >= "A") And _ (UCase(Mid(MJono, LpI, 1)) <= "Z") Then OutStr = OutStr & Mid(MJono, LpI, 1) End If LpI = LpI + 1 Loop Until LpI > LpL PutsaaStrLoopDoUntil = OutStr End Function Public Sub Test02() 1 MsgBox PutsaaStrLoopDoUntil("Seu45r34a4a%&#¤&va/(ssa TeÅÄÖs,ti1:;jo99912 no2") End Sub