On 8/2/2011 1:49 PM, Doug Geoffray wrote:
Scott,

The error is because of

MsgBox "In the phonebook your name would appear as:" &AlphabetizeForm(FirstName, LastName) &"Your phone number will appear as:" &PhoneNumber("(", AreaCode,")", Prefix, "-", LastFourNumbers)

It should be:

MsgBox "In the phonebook your name would appear as:" &AlphabetizeForm(FirstName, LastName) &"Your phone number will appear as:" &PhoneNumber("(", AreaCode,")", Prefix, "-", LastFourNumbers)

You called AlphabetizeForm with 6 parms when it only takes 3. Notice I removed the two parens and the dash as they are not needed since they are added in the AlphabetizeForm sub.

Doug

On 8/2/2011 1:40 PM, Scott Rumery wrote:
On 8/2/2011 12:51 PM, David wrote:
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





O.K. Thank you for your help. I am going to try this again with the error message so that you can see if you can help me to understand what I am doing wrong.

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





test.vbs - Microsoft VBScript runtime error (Dialog)
Line 7 Column 1 (Static Text)
Wrong number of arguments or invalid property assignment: 'PhoneNumber' (Static Text)
< 0x800A01C2 > (Static Text)



Thank you so much Doug, I made the changes and it works like I wanted.

Scott

Reply via email to