Well, since you did not tell exactly what error you keep getting, I don't
know to help you exactly. What I do notice though, in your provided example,
is your Ampersand (&). You need a space on both sides of it. like:
Firsname & Lastname
Secondly, when you divide a single command into several lines, like with
your MsgBox, you would need to end each of the lines with an underline
character:
MsgBox "This is your name: " _
& FirstName & Lastname
Hope this will be your fix.
----- Original Message -----
From: "Scott Rumery" <[email protected]>
To: <[email protected]>
Sent: Tuesday, August 02, 2011 6:34 PM
Subject: What am I doing wrong?
Hello, I am a beginner at scripting and I have been listening to Chip
Orange's Script writing class and trying to get an understanding for what
he is talking about. I am currently trying to work my way through class 3
and before I move on to class 4 I want to make sure that I understand all
of the concepts hthat he is teaching in class 3.
What I am attempting to do with one of the examples that Chip provides
four class 3 is to write a script that will display the way someones name
would appear in the phonebook, and I would also like to display that
persons phone number in that same message box. I think that I have almost
got it, but I keep getting an error that I cannot seem to get figured out.
Could someone please explain to me what I am doing wrong?
Scott Rumery
FirstName = InputBox("Enter your first name(Your Given Name): ")
LastName= InputBox ("Enter your last Name(Or Family Name): ")
AreaCode = InputBox("Enter your area code")
Prefix = InputBox("Enter First three numbers")
LastFourNumbers =InputBox("Enter Last Four Numbers")
MsgBox "In the phonebook your name would appear as:"
&AlphabetizeForm(FirstName, LastName) &"Your phone number will appear as:"
&PhoneNumber("(", AreaCode,")", Prefix, "-", LastFourNumbers)
function AlphabetizeForm(First, Last)
AlphabetizeForm = InitCap(Last) & ", " & InitCap(First)
end function
function PhoneNumber(AreaCode, Prefix, LastFourNumbers)
PhoneNumber = ("(") &(AreaCode) &(")") &(Prefix) &("-") &(LastFourNumbers)
end function
function InitCap(Word)
FirstLetter = Left(Word, 1)
Rest = Mid(Word, 2)
InitCap = UCase(FirstLetter) & LCase(Rest)
end function