|
-
Apr 3rd, 2011, 09:13 AM
#1
Thread Starter
New Member
-
Apr 3rd, 2011, 09:29 AM
#2
Re: Beginning Microsoft VB 2010
Welcome to VBForums 
Thread moved from 'Office Development' forum to 'VB.Net' (VB2002 and later) forum.
-
Apr 3rd, 2011, 10:26 AM
#3
Thread Starter
New Member
Re: Beginning Microsoft VB 2010
Thanks 
im so sorry for posting in wrong section too ^^
-
Apr 3rd, 2011, 10:37 AM
#4
Fanatic Member
Re: Beginning Microsoft VB 2010
Not sure, but I believe your messagebox line got a syntax error:
Code:
MessageBox.Show("Value of intNumber + 1 = " & intNumber.ToString, _ "Variables")
To:
Code:
MessageBox.Show("Value of intNumber + 1 = " & intNumber.ToString, "Variables")
The '_'-sign is used to make code flow over to the next line, like this:
Code:
Dim mystring As String = "This string is extremely long so I " & _
"use a '_' character to make it flow over correctly"
Or use the good ol' MsgBox:
Code:
MsgBox("Text to display")
Other than that there are no errors to be seen.
-
Apr 3rd, 2011, 10:42 AM
#5
Re: Beginning Microsoft VB 2010
*Ahh, beaten!*
Could you describe what you mean by "something went wrong"?
The only odd part I see is here:
Code:
MessageBox.Show("Value of intNumber + 1 = " & intNumber.ToString, _ "Variables")
See that "_" character? That's called the "line continuation operator". Since VB .NET doesn't use a character like ";" to mean "end of line", the syntax doesn't provide an immediate way for you to separate an expression over multiple lines of code. If you end a line with "_", that's a hint to the compiler that you have split an expression:
Code:
MessageBox.Show("Value of intNumber + 1 = " & intNumber.ToString(), _
"Variables")
In VB 2010, you don't *always* have to use the line continuation operator when splitting an expression, but there are still scenarios where it's needed.
Anyway, my guess is if you put the "_" on a line, you are not allowed to place any more code on that line. Either start a new line after it or delete the "_" from your code.
If that's not the problem, please include a detailed explanation of what you expect to happen and what's actually happening; make sure to include this in all posts.
-
Apr 3rd, 2011, 12:35 PM
#6
Fanatic Member
Re: Beginning Microsoft VB 2010
Haha, happened to be a few times too.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|