Example - Right Function

  1. ' The example uses the Right function to return the first of two words

    ' input by the user.

    Sub Main ()

    1. Dim LWord, Msg, RWord, SpcPos, UsrInp           ' Declare variables.

      Msg = "Enter two words separated by a space."

      UsrInp = InputBox(Msg)           ' Get user input.

      print UsrInp

      SpcPos = InStr(1, UsrInp, " ")          ' Find space.

      If SpcPos Then

      1. LWord = Left(UsrInp, SpcPos - 1)          ' Get left word.

        print "LWord: ";LWord

        RWord = Right(UsrInp, Len(UsrInp) - SpcPos)          ' Get right word.

        Msg = "The first word you entered is " & LWord

        Msg = Msg & "." & " The second word is "

        Msg = "The first word you entered is <" & LWord & ">"

        Msg = Msg & RWord & "."

      Else

      1. Msg = "You didn't enter two words."

      End If

      MsgBox Msg          ' Display message.

    End Sub