VBA/Excel/Access/Word/String Functions/InStr

Материал из VB Эксперт
Перейти к: навигация, поиск

Use MsgBox(), InStr(), Left(), Right() and Len() to read the first name and last name

 
Sub AboutUser()
    Dim fullName As String
    Dim firstName As String
    Dim lastName As String
    Dim space As Integer
    fullName = InputBox("Enter first and last name:")
    space = InStr(fullName, " ")
    firstName = Left(fullName, space - 1)
    lastName = Right(fullName, Len(fullName) - space)
    Debug.Print lastName & ", " & firstName
End Sub