Returns, Enter

whosyodaddy

Regular
Joined
Jun 23, 2003
Messages
83
When I write code to display text in the text bar how do i make Returns? For Example: when i write this:

TextBox1().Text = "Golden CH-6: Beat level 2 with 50,000 or more points Infinite missiles while in the car: Beat level 3 with 70,000 or more points, Get Mp model - poseidon guard: Get 130000 points and all 007 medallions for level 11, Get regenerative armor: Get 130000 points for level 11"

(in code view the whole thing is in ONE LINE).
it turns out like this in the textbox:

Golden CH-6: Beat level 2 with 50,000 or more points Infinite missiles while in the car: Beat level 3 with 70,000 or more points, Get Mp model - poseidon guard: Get 130000 points and all 007 medallions for level 11, Get regenerative armor: Get 130000 points for level 11.

But how would i make it turn out like this?:

Golden CH-6:

Beat level 2 with 50,000 or more points

Infinite missiles while in the car:

Beat level 3 with 70,000 or more points,

Get Mp model - poseidon guard:

Get 130000 points and all 007 medallions for level 11

Get regenerative armor:

Get 130000 points for level 11"


Please, Please, help! i know this is a simple question but i have no clue how to!! i am new, please help!
 
In C# you can use the escape character \n for newlines. Not sure about VB.. Environment.NewLine I think.
 
where would i post those codes? right after the text i want returned?

If (s.Equals("007 Agent Under Fire")) Then
TextBox1.Text += "Golden CH-6: Beat level 2 with 50,000 or more points Infinite missiles while in the car: Beat level 3 with 70,000 or more points, Get Mp model - poseidon guard: Get 130000 points and all 007 medallions for level 11, Get regenerative armor: Get 130000 points for level 11 " + ListBox1.SelectedItem.ToString()
ElseIf (s.Equals("Aggressive Inline")) Then
TextBox1().Text = "Bam!"
End If

if i want a return in between where it says points and Infinite Missles, where would i put the code you gave me?
 
Last edited:
Just to clarify, vbCrLf is the same as both Chr(13) and Chr(10) together (in that order).

However, it is best to use Environment.NewLine, I think.Since .NET can be used across different platform, and since other OS's (such as Linux and MacOS) do not use CrLf as the newline identifier, CrLf may not work on other OSs. Because vbCrLf is hardcoded as Cr and Lf, other operating systems may not interpret it correctly. However, implementations of the .NET FX on other platforms will let Environment.NewLine use the correct constant (Lf, Cr, whatever), so the code will, in theory, work on other platforms.
 
Visual Basic:
If (s.Equals("007 Agent Under Fire")) Then
  TextBox1.Text += "Golden CH-6: Beat level 2 with 50,000 or more points " [b] & Environment.NewLine & [/b] _
  "Infinite missiles while in the car: Beat level 3 with 70,000 or more points, " & _
  "Get Mp model - poseidon guard: Get 130000 points and all 007 medallions for level 11, Get " & _
  regenerative armor: Get 130000 points for level 11 " & ListBox1.SelectedItem.ToString()
ElseIf (s.Equals("Aggressive Inline")) Then
  TextBox1().Text = "Bam!"
End If
I added the line-break character "_" to allow the line to break over to multiple lines.
 
hey thanks, so if i do '& _" after i do System.Environment.NewLine, it creats a new line instead of always doing "System.Environment.NewLine"?
 
No, no.. sorry for confusing you there. Heh.

_ in the IDE means that you can break one line into two without actually affecting the way the code runs.

For example,

Visual Basic:
myString = "The quick brown fox " & _
  "jumps over the lazy dog!"
is equivilent to
Visual Basic:
myString = "The quick brown fox " & "jumps over the lazy dog!"
But it's broken into two lines so you can see more of it at once. You still need Environment.NewLine.

The '_' character is for aesthetic purposes only.
 
oh thanks! and to make it easier to read, how would i bold a certain part?

If (s.Equals("007 Agent Under Fire")) Then
TextBox1.Text += Golden CH-6 & System.Environment.NewLine & Beat level 2 with 50,000 or more points "
"Infinite missiles while in the car: Beat level 3 with 70,000 or more points, " & _
"Get Mp model - poseidon guard: Get 130000 points and all 007 medallions for level 11, Get " & _
regenerative armor: Get 130000 points For level 11 " & ListBox1.SelectedItem.ToString()
ElseIf (s.Equals("Aggressive Inline")) Then
TextBox1().Text = "Bam!"
End If

how would i Bold Golend CH-6 in visual basic? (NET)
 
You'll need to use the RichTextBox for that; that's a bit more complicated.

Once you put the text in the RichTextBox, you can do something like this:

Visual Basic:
RichTextBox1.SelectionStart = 50 'replace 50 with the position of the first character you want to make bold
RichTextBox1.SelectionLength = 10 'replace 10 with the length of the text you want to make bold
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Bold) 'make the text bold

RichTextBox1.SelectionStart = RichTextBox1.Text.Length 'move the caret to the end
RichTextBox1.SelectionLength = 0 'deselect all text

Consult your MSDN for more info. :)

[edit]Ah mutant, you beat me this time :p[/edit]
 
if i wanted 2 new lines would i do like "System.Environment.NewLine & System.Environment.NewLine" ?? ok i tried that and that worked. THANKS TO EVERYBODY!!!
 
Last edited:
Back
Top