Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hey guys,

i am trying to make a tutorial series on how to get started on making a programming language and one of the first tutorials are to do this:

VB
for each a as string in textbox1.text.split(controlchars.lf)
     if a.startswith("print ")
          textbox2.text &= a.substring(6
     end if
next


if you go and run this code, it will run just fine. but you will not be able to make new lines. i want to be able to make a new line with the command 'newline' but i don't know how to. can you guys please give me an answer that is in the 'for each' statement? this is a sample code that you can try:

print Hello World
newline
print Something


result:

Hello World
Something
Posted

Don't you think it would be a good idea for you to understand what is going on and how to do things before you start writing tutorials?

I'm pretty sure that any tutorial written by a beginner is going to miss out a lot of important stuff. For example, the lack of use of the StringBuilder class in your example, the use of Visual studio default names...

Try this:
VB
textBox2.Text = "Hello" + Environment.NewLine & "Goodbye"
 
Share this answer
 
Comments
Member 8378691 28-May-12 6:51am    
i konw exactly what is going on, i havn't done programming languages like this for so long that i have forgot how to do this. Can you please just give this to me in the for each statement?
Hi,
Please check for this-
Have you set your textbox property to multiline?
try using VbCrlf it is used for newline in VB.NET
 
Share this answer
 
Using foreach is simple enough:

VB
for each a as string in textbox1.lines()
.
.
next
 
Share this answer
 
Comments
Member 8378691 28-May-12 17:16pm    
that isn't what I wanted. I want the code to be able to make new lines in TextBox2. If you run my code in the question, it doesn't allow new lines in TextBox2. I want to be able to have new lines in TextBox2. Can you please give me a code for this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900