Mid() returns Any portion of a string
Sub midDemo()
Dim userName As String
Dim firstName As String
Dim spaceLoc As Integer
Dim strLength As Integer
Dim lastName As String
userName = " First Last"
spaceLoc = InStr(1, userName, " ")
firstName = Left(userName, spaceLoc - 1)
strLength = Len(firstName)
lastName = Mid(userName, 1, 5)
Debug.Print lastName
End Sub
Related examples in the same category