whosyodaddy Posted June 24, 2003 Posted June 24, 2003 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! Quote
wyrd Posted June 24, 2003 Posted June 24, 2003 In C# you can use the escape character \n for newlines. Not sure about VB.. Environment.NewLine I think. Quote Gamer extraordinaire. Programmer wannabe.
Leaders dynamic_sysop Posted June 24, 2003 Leaders Posted June 24, 2003 you can use a few ways System.Environment.NewLine '// return Chr(10)'/// also starts a new line Chr(13)'/// so does this VbCrlf'/// from visual basic , but still works Quote
whosyodaddy Posted June 24, 2003 Author Posted June 24, 2003 (edited) 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? Edited June 24, 2003 by whosyodaddy Quote
*Experts* Volte Posted June 24, 2003 *Experts* Posted June 24, 2003 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. Quote
*Experts* Volte Posted June 24, 2003 *Experts* Posted June 24, 2003 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 IfI added the line-break character "_" to allow the line to break over to multiple lines. Quote
whosyodaddy Posted June 24, 2003 Author Posted June 24, 2003 hey thanks, so if i do '& _" after i do System.Environment.NewLine, it creats a new line instead of always doing "System.Environment.NewLine"? Quote
*Experts* Volte Posted June 24, 2003 *Experts* Posted June 24, 2003 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, myString = "The quick brown fox " & _ "jumps over the lazy dog!"is equivilent tomyString = "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. Quote
whosyodaddy Posted June 24, 2003 Author Posted June 24, 2003 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) Quote
*Experts* mutant Posted June 24, 2003 *Experts* Posted June 24, 2003 Normal TextBox doesnt support things like that, use RichTextBox if you want formatting. Quote
*Experts* Volte Posted June 24, 2003 *Experts* Posted June 24, 2003 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: 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] Quote
whosyodaddy Posted June 24, 2003 Author Posted June 24, 2003 (edited) 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!!! Edited June 24, 2003 by whosyodaddy Quote
*Experts* Volte Posted June 24, 2003 *Experts* Posted June 24, 2003 Yep; without the quotes though obviously. :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.