473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

New Line in TextBox

Hi.. Would really be glad to have some help on textBox .

From what i know of textbox , the old value that u assign to it will always be replace by the new ones. Example :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim array(4) As String
  3.         array(0) = 6
  4.         array(1) = 6
  5.         array(2) = 6
  6.         array(3) = 6
  7.         array(4) = 6
  8.         For n As Integer = 0 To 4
  9.  
  10.             TextBox1.Text = array(n)
  11.  
  12.         Next
  13.  
  14.     End Sub
The output will only be one 6 on the textBox. However i want five 6 to be listed on the textbox. Is there a line break or something so that i can print all things in the array? I know i can use the listbox to achieve that but then i am not able to copy the words from the listbox
Jun 18 '07 #1
12 4490
hariharanmca
1,977 1GB
Hi.. Would really be glad to have some help on textBox .

From what i know of textbox , the old value that u assign to it will always be replace by the new ones. Example :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim array(4) As String
  3.         array(0) = 6
  4.         array(1) = 6
  5.         array(2) = 6
  6.         array(3) = 6
  7.         array(4) = 6
  8.         For n As Integer = 0 To 4
  9.  
  10.             TextBox1.Text = array(n)
  11.  
  12.         Next
  13.  
  14.     End Sub
The output will only be one 6 on the textBox. However i want five 6 to be listed on the textbox. Is there a line break or something so that i can print all things in the array? I know i can use the listbox to achieve that but then i am not able to copy the words from the listbox

Make the TextBox Property Multi line =True

and

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim array(4) As String
  3.         array(0) = 6
  4.         array(1) = 6
  5.         array(2) = 6
  6.         array(3) = 6
  7.         array(4) = 6
  8.         For n As Integer = 0 To 4
  9.  
  10.             TextBox1.Text = array(n) & vbcr
  11.  
  12.         Next
  13.  
  14.     End Sub
Jun 18 '07 #2
Make the TextBox Property Multi line =True

and

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim array(4) As String
  3.         array(0) = 6
  4.         array(1) = 6
  5.         array(2) = 6
  6.         array(3) = 6
  7.         array(4) = 6
  8.         For n As Integer = 0 To 4
  9.  
  10.             TextBox1.Text = array(n) & vbcr
  11.  
  12.         Next
  13.  
  14.     End Sub
Hi i have set the multiline to true and edit this line
TextBox1.Text = array(n) & vbcr

However the output display is still the same. only one 6
Jun 18 '07 #3
hihi forgot to mention that i am using VB 2005 express edition. Thanks!
Jun 18 '07 #4
Killer42
8,435 Expert 8TB
hihi forgot to mention that i am using VB 2005 express edition. Thanks!
This is a fundamental rule - assigning a value to a property or variable replaces what was there previously. You cannot append a value to it.

What you need to do is think carefully about what you want to put there. In a case like this, what you want to put there is the old value plus the new value, isn't it? So put that in there.
Jun 18 '07 #5
hariharanmca
1,977 1GB
hihi forgot to mention that i am using VB 2005 express edition. Thanks!

what'er Vb version this is also a way. okay Explain your problem with some other example...
Jun 19 '07 #6
Killer42
8,435 Expert 8TB
I'll give you another hint.

If you have a string variable, and you want to add something onto the end of it, what do you do?

Let's say MyString = "ABC"
How would you add, say, a "D" onto the end, using code?
You do the same with a textbox.
Jun 19 '07 #7
hariharanmca
1,977 1GB
I'll give you another hint.

If you have a string variable, and you want to add something onto the end of it, what do you do?

Let's say MyString = "ABC"
How would you add, say, a "D" onto the end, using code?
You do the same with a textbox.

okay I got the prob,

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         Dim array(4) As String
  3.         array(0) = 6
  4.         array(1) = 6
  5.         array(2) = 6
  6.         array(3) = 6
  7.         array(4) = 6
  8.         TextBox1.Text = ""
  9.         For n As Integer = 0 To 4
  10.  
  11.             TextBox1.Text = TextBox1.Text & array(n)  
  12.         Next
  13.  
  14.     End Sub
  15.  
  16.  
  17. Change the Code line to : 
  18.               TextBox1.Text = TextBox1.Text & array(n) & vbcr
Jun 19 '07 #8
Killer42
8,435 Expert 8TB
Oh nuts! I was trying to encourage dr3amxstar to work it out.

Oh well...

Keep in mind dr3amxstar, you only want to add on the vbcrlf (actually, I'd recommend vbNewLine) if you want a line break between the values. You can stick them together without the breaks.
Jun 19 '07 #9
hukam
8
hello
you can use the following statement while at the time of inserting text

text1.text=text1.text & array(n) & vbcrlf

thanks
Jun 19 '07 #10
Oops i thought nobody was replying to my thread and i managed to figured it out :D anyway thanks for all the help given!! I really did learn alot from this forum :D

Expand|Select|Wrap|Line Numbers
  1.  TextBoxForm2c.AppendText(source3 & vbCrLf & accuracy & vbCrLf)
Jun 25 '07 #11
Killer42
8,435 Expert 8TB
Glad we could help.

It's good that you were able to work it out. I prefer to try and help people work out the answer rather than just giving it to them outright, anyway. Copy/paste generally doesn't teach you much.
Jun 25 '07 #12
Glad we could help.

It's good that you were able to work it out. I prefer to try and help people work out the answer rather than just giving it to them outright, anyway. Copy/paste generally doesn't teach you much.

yup! by trying out myself i understand what i am doing :D
Jun 26 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Nurchi BECHED | last post by:
Hello, All! I have created an application with a multiline textbox on the form. When I press a button, it has to show something and then break the line and show something else. I tried "\n",...
2
by: Mr.Baha | last post by:
Hello, I have a situation where I am appending text to a multi-line (rich)textbox in a C# form. Now depending on which event does the appendtext, i want to distinguish the lines in the textbox by...
1
by: VMI | last post by:
In my Windows app, if I'm in a multi-line textbox and I'm writing a postal address (ie. write ist line and press <Enter>, write 2nd line and press <Enter>, etc...) how can I make sure that the...
6
by: Maziar Aflatoun | last post by:
Hi, I have a little application that reads a text file line-by-line and processes each line depending on the CVS values. Now I want to change my program to capture this from a textbox. How do...
2
by: Mike | last post by:
I need my textbox to work more smoothly with respect to line breaks. When I have data pulled from the database into a textbox there are hard line breaks at the end of each line (by definition how...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
4
by: zoneal | last post by:
I have a multi line textbox with word wrap enabled. Is it possible to write code to check if the text of the textbox has continued into the next line and then count the amount of lines? If not...
2
by: garyusenet | last post by:
I have a multi line text box, i'd like to store the contents of this textbox to a text file. However when I write the value of ' textbox.text ' to the file it is written verbatim spanning many...
2
by: Boki | last post by:
Hi All, My textbox is a queue stack, after processing a line, I need to process next line, and the first line should be removed to indicate progress. Should we check the new line by ourself ?...
3
by: Gregory Leck | last post by:
I can import a .txt document into a TextBox Each line in the TextBox contains a URL, for example, http://www.whateverdomain.com I would like to convert each URL to the following format: <a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.