Ignore sign?

darklight

Member
Joined
May 3, 2007
Messages
18
Programming Experience
1-3
Is there an ignore sign? I don't want it commented i'm trying to add ' but it will comment it. Heres what i'm trying to do:

VB.NET:
[SIZE=2]TextBox2.Text = ([/SIZE][SIZE=2][COLOR=#a31515]"function"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE][SIZE=2] & TextBox3.Text & [/SIZE][SIZE=2][COLOR=#a31515]"() { commandtoserver(""'messageSent', & """[/COLOR][/SIZE][SIZE=2] & TextBox1.Text & [/SIZE][SIZE=2][COLOR=#a31515]");}"[/COLOR][/SIZE][SIZE=2])
[/SIZE]
 
would something like this work:
TextBox2.Text = "function " & TextBox3.Text & "() { commandtoserver("" 'messageSent', " & """" & TextBox1.Text & """);}"
 
Use String.Format:
VB.NET:
[SIZE=2]TextBox1.Text = [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515]"function {0}() {{commandtoserver(""messageSent"", ""{1}"");}}"[/COLOR][/SIZE][SIZE=2], TextBox2.Text, TextBox3.Text)[/SIZE]
This would output if params were "A" and "B":
function A() {commandtoserver("messageSent", "B");}
 
Use the Environment.Newline command

or use the vbCrLf constant. Example:

Text = "This is one line" & vbCrLf & "This is the second line."
 
If you're building much text use the System.Text.StringBuilder instead, it features methods Append, AppendLine and AppendFormat (that works same as String.Format).
 
Here's what i am basicly doing:

http://76.98.160.254/torque/Default.aspx

And also:

lol, I feel like a noob xD

Anyway, why does this keep calling both?

VB.NET:
[SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] advC = 1 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]GoTo[/COLOR][/SIZE][SIZE=2] advcode [/SIZE][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][SIZE=2] 
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] advC = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] _
TextBox2.Text = ([/SIZE][SIZE=2][COLOR=#a31515]"function"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE][SIZE=2] & TextBox3.Text & [/SIZE][SIZE=2][COLOR=#a31515]"()"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" {"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" commandtoserver("[/COLOR][/SIZE][SIZE=2] & Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]"messageSent"[/COLOR][/SIZE][SIZE=2] & Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]","[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][SIZE=2] & TextBox1.Text & [/SIZE][SIZE=2][COLOR=#a31515]""");"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]"}"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Computer.FileSystem.WriteAllText([/SIZE][SIZE=2][COLOR=#a31515]"c:\Documents and Settings\"[/COLOR][/SIZE][SIZE=2] & Environment.UserName & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"Desktop"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"code.txt"[/COLOR][/SIZE][SIZE=2], TextBox2.Text, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2])
MsgBox([/SIZE][SIZE=2][COLOR=#a31515]"The code was saved as code.txt on your desktop."[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#a31515]"Note"[/COLOR][/SIZE][SIZE=2])
 
advcode:
TextBox2.Text = ([/SIZE][SIZE=2][COLOR=#a31515]"function"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE][SIZE=2] & TextBox3.Text & [/SIZE][SIZE=2][COLOR=#a31515]"(%"[/COLOR][/SIZE][SIZE=2] & TextBox6.Text & [/SIZE][SIZE=2][COLOR=#a31515]")"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" {"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" commandtoserver("[/COLOR][/SIZE][SIZE=2] & Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]"messageSent"[/COLOR][/SIZE][SIZE=2] & Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]","[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"%"[/COLOR][/SIZE][SIZE=2] & TextBox6.Text & [/SIZE][SIZE=2][COLOR=#a31515]");"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]"}"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Computer.FileSystem.WriteAllText([/SIZE][SIZE=2][COLOR=#a31515]"c:\Documents and Settings\"[/COLOR][/SIZE][SIZE=2] & Environment.UserName & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"Desktop"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"codeAdv.txt"[/COLOR][/SIZE][SIZE=2], TextBox2.Text, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2])
MsgBox([/SIZE][SIZE=2][COLOR=#a31515]"The code was saved as codeadv.txt on your desktop."[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#a31515]"Note"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE]
 
Last edited:
VB.NET:
[SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Button1.Click[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] advC = 1 [/SIZE][SIZE=2][COLOR=#0000ff]Then [/COLOR][/SIZE][SIZE=6][COLOR=red][B]GoTo [/B][/COLOR][/SIZE]advcode [SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] advC = 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][SIZE=2] _[/SIZE]
[SIZE=2]TextBox2.Text = ([/SIZE][SIZE=2][COLOR=#a31515]"function"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE][SIZE=2] & TextBox3.Text & [/SIZE][SIZE=2][COLOR=#a31515]"()"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" {"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" commandtoserver("[/COLOR][/SIZE][SIZE=2] & Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]"messageSent"[/COLOR][/SIZE][SIZE=2] & Chr(39)[/SIZE]
[SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]","[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]""""[/COLOR][/SIZE][SIZE=2] & TextBox1.Text & [/SIZE][SIZE=2][COLOR=#a31515]""");"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]"}"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Computer.FileSystem.WriteAllText([/SIZE][SIZE=2][COLOR=#a31515]"c:\Documents and Settings\"[/COLOR][/SIZE][SIZE=2] & Environment.UserName & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"Desktop"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"code.txt"[/COLOR][/SIZE]
[SIZE=2], TextBox2[/SIZE]
[SIZE=2].Text, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#a31515]"The code was saved as code.txt on your desktop."[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#a31515]"Note"[/COLOR][/SIZE][SIZE=2])[/SIZE]
 
[SIZE=2]advcode:[/SIZE]
[SIZE=2]TextBox2.Text = ([/SIZE][SIZE=2][COLOR=#a31515]"function"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]" "[/COLOR][/SIZE][SIZE=2] & TextBox3.Text & [/SIZE][SIZE=2][COLOR=#a31515]"(%"[/COLOR][/SIZE][SIZE=2] & TextBox6.Text & [/SIZE][SIZE=2][COLOR=#a31515]")"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" {"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]" commandtoserver("[/COLOR][/SIZE][SIZE=2] & [/SIZE]
[SIZE=2]Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]"messageSent"[/COLOR][/SIZE][SIZE=2] & Chr(39) & [/SIZE][SIZE=2][COLOR=#a31515]","[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"%"[/COLOR][/SIZE][SIZE=2] & TextBox6.Text & [/SIZE][SIZE=2][COLOR=#a31515]");"[/COLOR][/SIZE][SIZE=2] & vbCrLf & [/SIZE][SIZE=2][COLOR=#a31515]"}"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Computer.FileSystem.WriteAllText([/SIZE][SIZE=2][COLOR=#a31515]"c:\Documents and Settings\"[/COLOR][/SIZE][SIZE=2] & Environment.UserName & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"Desktop"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"\"[/COLOR][/SIZE][SIZE=2] & [/SIZE][SIZE=2][COLOR=#a31515]"codeAdv.[/COLOR][/SIZE]
[SIZE=2][COLOR=#a31515]txt"[/COLOR][/SIZE][SIZE=2], TextBox2.Text, [/SIZE][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#a31515]"The code was saved as codeadv.txt on your desktop."[/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Information, [/SIZE][SIZE=2][COLOR=#a31515]"Note"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

Never, ever, ever, (ever) use GoTo. Ever. Period.

At the risk of sounding rude, your code is a mess. Follow JohnH's advice and use String.Format, because what you've written there is so ugly and confusing I dont even want to read it, and a developer who has to maintain it wont want to either..

Here are some pointers:
Give your textboxes proper names, not the default TextBox1, TextBox2 - that way when you post a bunch of uncommented code on a free forum we can at least guess at what things do.. Your code will self-comment and become more readable and maintainable. In 3 months time when you revisit this code, youll be glad you named your variables properly

You dont need brackets around string concatenation; it is not a mathematical operation

Prefer use of MessageBox.Show to MsgBox

Dont stop and start strings all the time. The following are equivalent, but only one looks a mess:
Dim s as String = "Hello world"
Dim s as String = "He" & "l" & "l" & "o" & " " & "w" & "or" & "l" & "d" & "" & "" & "" & "" & ""
 
Prefer use of MessageBox.Show to MsgBox



I noticed in a recent thread that MsgBox is preferred to MessageBox.Show according to msdn's coding convention.

Also maybe it's the fact that I got into programming by wasting time on my TI graphing calculator in class all day in middle school (it had no loop that I knew of, but I figured out label/goto pretty quick) but I've always thought there were some situations where goto could be cleaner than the alternatives.
 
Back
Top