LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 533 users online 211554 members 1500 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
Rtheory
Cool Things: Overly-religious Christians (Y)
Mood: Sensitive
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
5 online / 35 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

VB code errors
Replies: 11Last Post Feb. 14, 2008 8:48pm by Ethryx
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( SilverDragon1Wings )


Executive
Reply
When I ran the debugger for VB, after writing in my code, it gave me several errors that I don't know how to fix.

The errors involve the statement I made for what to say after the command button is clicked. Here is the sentence I wrote:

'create message
       message = "You have entered " firstName & " " & lastName & " as a new customer." vbCR
       firstName & "'s address is: " & streetAddress & "," & city & "," & state & "," & zipCode & "."

THE TWO indented areas indicate the start of the lines {meaning that in the program it only takes up two lines}

the & sign {after firstName} which connects the statement of variables and string literals together has an error that reads "Method arguments must be enclosed in parentheses"

Then for the same sign, there is another error "Expression is expected."

for the string literal 'firstName' the error reads "Expression is not a method."

And the last error reads "End of statement expected" for the first line of my sentence.

How do I fix these errors? I wrote the sentence out how I was instructed to by my professor, did I make an error in writing it? {She didn't give the exact sentence to write, just how to write it.}

HELP!


8:21 pm on Feb. 14, 2008 | Joined: Sep. 2005 | Days Active: 269
Join to learn more about SilverDragon1Wings New York, United States | Straight Female | Posts: 902 | Points: 3,617
Ethryx


Soothsayer

Patron
Tech Support Leader
Reply
You need an & right before the variable firstname

-------
Peek-a-boo!
DragDrop Image Hosting Fast. Free. Easy.

8:21 pm on Feb. 14, 2008 | Joined: Jan. 2007 | Days Active: 527
Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,855 | Points: 13,236
helloangel666


Dairy Product Addict
Reply
okay


-------
guys wit long hair rock!

8:22 pm on Feb. 14, 2008 | Joined: Nov. 2007 | Days Active: 92
Join to learn more about helloangel666 Washington, United States | Straight Female | Posts: 188 | Points: 1,251
( SilverDragon1Wings )


Executive
Reply
Quote: from Ethryx at 11:21 pm on Feb. 14, 2008

You need an & right before the variable firstname

It got rid of the errors for the & sign but now says "syntax error"


8:22 pm on Feb. 14, 2008 | Joined: Sep. 2005 | Days Active: 269
Join to learn more about SilverDragon1Wings New York, United States | Straight Female | Posts: 902 | Points: 3,617
neotreo


Enlightened One

Patron
Reply
wait... was that... basic? ive never actually seen it...

-------
Do Not Meddle In The Affairs Of Dragons,
For You Are Crunchy and Good with Ketchup
/b/ does it for the lulz!!!

8:23 pm on Feb. 14, 2008 | Joined: July 2006 | Days Active: 520
Join to learn more about neotreo Pennsylvania, United States | Straight Male | Posts: 7,722 | Points: 15,327
Ethryx


Soothsayer

Patron
Tech Support Leader
Reply
Code:

message = "You have entered " & firstName & " " & lastName & " as a new customer." & vbCrLf & firstName & "'s address is: " & streetAddress & "," & city & "," & state & "," & zipCode & "."

Thats the correct way to do it.

btw, make sure thats all on 1 line.

Post edited at 8:24 pm on Feb. 14, 2008 by Ethryx

-------
Peek-a-boo!
DragDrop Image Hosting Fast. Free. Easy.


8:23 pm on Feb. 14, 2008 | Joined: Jan. 2007 | Days Active: 527
Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,855 | Points: 13,236
( SilverDragon1Wings )


Executive
Reply
Quote: from Ethryx at 11:23 pm on Feb. 14, 2008

Code:

message = "You have entered " & firstName & " " & lastName & " as a new customer." & vbCrLf & firstName & "'s address is: " & streetAddress & "," & city & "," & state & "," & zipCode & "."

Thats the correct way to do it.

btw, make sure thats all on 1 line.


Make sure the whole sentence is on line one? Shouldn't you write it on two lines?

Thanks, the code you pasted did get rid of the errors, but the & sign in front of firstName on the second line still says syntax error.


8:31 pm on Feb. 14, 2008 | Joined: Sep. 2005 | Days Active: 269
Join to learn more about SilverDragon1Wings New York, United States | Straight Female | Posts: 902 | Points: 3,617
Ethryx


Soothsayer

Patron
Tech Support Leader
Reply
If you want to do this on two different lines, then you have to do it like this:
Code:

message = "You have entered " & firstName & " " & lastName & " as a new customer." & vbCrLf

message = message & firstName & "'s address is: " & streetAddress & "," & city & "," & state & "," & zipCode & "."

Also, may I ask what version of the language you are doing this in? Is this in .NET?

-------
Peek-a-boo!
DragDrop Image Hosting Fast. Free. Easy.


8:34 pm on Feb. 14, 2008 | Joined: Jan. 2007 | Days Active: 527
Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,855 | Points: 13,236
( SilverDragon1Wings )


Executive
Reply
GAAAA! It is VB.NET version 8...Sorry about that my boyfriend double checked it for me, and it apparently wasn't what I thought it was...

Thank you so much for your help, I appreciate it!

Post edited at 8:41 pm on Feb. 14, 2008 by SilverDragon1Wings


8:36 pm on Feb. 14, 2008 | Joined: Sep. 2005 | Days Active: 269
Join to learn more about SilverDragon1Wings New York, United States | Straight Female | Posts: 902 | Points: 3,617
Ethryx


Soothsayer

Patron
Tech Support Leader
Reply
Okay, I figured it was .NET since you said you were taking a class on VB and they hardly teach the older versions anymore haha. But here is a working example of what you need:

Code:

Dim Message As String, firstName As String, lastName As String, streetAddress As String, city As String, state As String, zipCode As String
       firstName = "Joe"
       lastName = "Smith"
       streetAddress = "123 Popcorn Street"
       city = "Bigville"
       state = "NY"
       zipCode = "11777"
       Message = "You have entered " & firstName & " " & lastName & " as a new customer." & vbCrLf & firstName & "'s address is: " & streetAddress & "," & city & "," & state & "," & zipCode & "."

       MsgBox(Message)



-------
Peek-a-boo!
DragDrop Image Hosting Fast. Free. Easy.


8:38 pm on Feb. 14, 2008 | Joined: Jan. 2007 | Days Active: 527
Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,855 | Points: 13,236
( SilverDragon1Wings )


Executive
Reply
Yea, that is basically the code that I wrote for it, minus a few things. The whole concatenate thing confuses me though, which is why I had all of those errors.

8:43 pm on Feb. 14, 2008 | Joined: Sep. 2005 | Days Active: 269
Join to learn more about SilverDragon1Wings New York, United States | Straight Female | Posts: 902 | Points: 3,617
Ethryx


Soothsayer

Patron
Tech Support Leader
Reply
Well, just think of it like a math problem. If I told you A + B = C, that makes sense. But if I said A B = C, then you really aren't sure what to do with A and B to get the answer, C. You could assume multiply them but what if they were numbers, like 15 20 = C. You wouldn't really know what to do with them to get that answer -- C. So, in Visual Basic, always use & when you are going back and forth between variables and strings. If you ever get weird errors like you were getting earlier, just double check your coding and see if you missed any &'s where you need them. You'll get the hang of it

-------
Peek-a-boo!
DragDrop Image Hosting Fast. Free. Easy.

8:48 pm on Feb. 14, 2008 | Joined: Jan. 2007 | Days Active: 527
Join to learn more about Ethryx New York, United States | Straight Male | Posts: 4,855 | Points: 13,236
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic