Attribute VB_Name = "Module11" Function SolunA1ArvonPituus() As Long SolunA1ArvonPituus = Len(ActiveSheet.Range("A1").Value) End Function Sub TestaaSolunA1ArvonPituus() MsgBox SolunA1ArvonPituus End Sub Sub LenTesti() Dim M As Boolean M = True MsgBox (Len(M)) End Sub Sub MidTesti() MsgBox Mid("testijono", 3, 4) 'stij MsgBox Mid("testijono", 6, 4) 'jono MsgBox Mid("testijono", 6) 'jono MsgBox Mid("testijono", 1) 'testijono MsgBox Mid("testijono", 1, 9) 'testijono MsgBox Mid("testijono", 10) '(ei mitään) MsgBox Mid("testijono", 1, 1) 't MsgBox Mid("testijono", Len("testijono")) 'o End Sub Sub LeftTesti() MsgBox (Left("testijono", 1)) 't MsgBox (Left("testijono", 5)) 'testi MsgBox (Left("testijono", 9)) 'testijono End Sub Sub RightTesti() MsgBox (Right("testijono", 1)) 'o MsgBox (Right("testijono", 4)) 'jono MsgBox (Right("testijono", 9)) 'testijono End Sub Private Function MJono7Loput(ByVal MJono As String) As String If Len(MJono) > 6 Then MJono7Loput = Mid(MJono, 7, Len(MJono) - 6) Else MJono7Loput = "" End If End Function Sub TestaaMJono7Loput() MsgBox MJono7Loput("1234AJ901") End Sub Private Function MJonoAlku5(ByVal MJono As String) As String If Len(MJono) > 5 Then MJonoAlku5 = Left(MJono, 5) Else MJonoAlku5 = "" End If End Function Sub TestaaMJonoAlku5() MsgBox MJonoAlku5("20100 Turku") End Sub Sub InStrTesti() MsgBox InStr(1, "Esimerkki", "kk") MsgBox InStr(1, "Esimerkki", "kk") MsgBox InStr(8, "Esimerkki", "k") MsgBox InStr(1, "Esimerkki", "kkk") MsgBox InStr(8, "Esimerkki", "kk") End Sub Sub TrimDemo() MsgBox "-" & Trim(" tes ti ") & "-" End Sub Sub SpaceDemo() MsgBox "-" & "testi" & Space(12 - Len("testi")) & "-" End Sub