Article ID: 141287
Article Last Modified on 8/17/2005
Sub String_Len()
' Sets MyString.
MyString = InputBox("Enter some text.")
' Displays length of string.
MsgBox Prompt:="The length of the string is " &_
Len(MyString) &" characters."
End Sub
Sub String_Left()
' Sets MyString.
MyString = InputBox("Enter some text.")
StringLen = Len(MyString)
Pos = InputBox("Please enter a number from 1 to " & StringLen)
' Takes the left number of specified characters.
Result = Left(MyString, Pos)
' Displays the result.
MsgBox Prompt:="The left " & Pos & " characters of """ & _
MyString & """ are: " & _
Chr(13) & Result
End Sub
Sub String_Right()
' Sets MyString.
MyString = InputBox("Enter some text.")
StringLen = Len(MyString)
Pos = InputBox("Please enter a number from 1 to " & StringLen)
' Takes the right number of specified digits.
Result = Right(MyString, Pos)
' Displays the result.
MsgBox Prompt:="The right " & Pos & " characters of """ & _
MyString & """ are: " & _
Chr(13) & Result
End Sub
Sub String_Mid()
' Sets MyString.
MyString = InputBox("Enter some text.")
' Sets starting position.
StartPos = InputBox _
("Give me a starting position (1 to " _
& Len(MyString) & ")")
' Determines length of string of text.
StringLen = Len(MyString) - StartPos + 1
' Sets number of characters.
NumChars = InputBox _
("How many characters would you like? (From 1 to " & _
StringLen & ")")
MsgBox prompt:="The result is: " & _
Mid(MyString, StartPos, NumChars)
End Sub
Len
Right
Left
Mid
Additional query words: 5.00c 8.00 XL97 XL98 XL7 XL5 XL
Keywords: kbhowto kbprogramming kbdtacode KB141287