473,395 Members | 1,766 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,395 software developers and data experts.

loading a textbox with several strings of text (multi-lines of text)

phillipsbrian
I need to display several lines of text in a VB textbox (VB 2005 Xpress). my aproach to test the possibilty has been as the following code:

dim I as Integer
for I = 1 to 10
Textbox1.text = "hgjhgjhgjhgjhg" + chr(13)
next

this produces only one line at the top of the box which is overwriten 10 times.

Please advise on what I am doing wrong, thank you
May 27 '07 #1
4 1327
Killer42
8,435 Expert 8TB
Ok, every time you set the value of a property (eg the .Text property) you are replacing the old value. So you need to think carefully about exactly what you want to put in there each time around the loop.

Seems to me, what you want to set it to is the old value of the property, with the new value stuck on the end.
May 28 '07 #2
many thanks, I had not realised that the texbox cleared each time it was addressed, seems strange to me that should be so!
Thats one hurdle out the way.
greetings

my routine for testing is now as here:
Dim I As Integer
Dim mytext(20), last(20) As String
For I = 1 To 20
last(I) = Str(I) & "------------- " & Rnd(5) & Chr(13) & Chr(10)
mytext(I) = last(I)
TextBox9.Text = TextBox9.Text & mytext(I)
May 28 '07 #3
Killer42
8,435 Expert 8TB
many thanks, I had not realised that the texbox cleared each time it was addressed, seems strange to me that should be so!
You need to stop looking at it that way. It's a property, which is just like a variable connected to a control. When you place a value in a variable (or property) it replaces the prior value. That's all there is to it.

You need to learn to do a lot of that sort of generalisation in programming, and not treat each thing as a special case.

As for strange, well... that's practically the definition of programming. :)
May 28 '07 #4
many thanks, I will get there in the end. VB is relatively new to me, I used to do a lot of assembler programming but that is not so helpful in relation to VB. or perhaps my age is telling. thanks again. Brian
May 28 '07 #5

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

Similar topics

0
by: Piotr | last post by:
I need a VBA macro to copy all text from text objects in the igrafx flowcharter Diagram to clipboard or to save it to a text file (in order to count the text I translated). I tried the...
3
by: Patrick De Ridder | last post by:
My textBox comes on with all the text selected. Setting "hide selection" to "true" or using SelectedText or SelectedTextLength will not stop the highlighting. How do I get rid of the text pre-...
2
by: Hareth | last post by:
i got the idea "form.textbox.text = label.text" from vb... i tried it in C# but it generated errors i found a diff example from :...
4
by: Maileen | last post by:
Hi, I would like to do something like in C++. I would like to store several strings, integer,... in something which should be like a vector, or list. ex : "line1","test",5 "line2","good",91...
0
by: abc my vclass | last post by:
which properties to focus automatic highlight text on text when on fous?
1
by: Fir5tSight | last post by:
Hi, I have a TextBox, textAddress, that's defined as an array of text strings. Currently I only have a single line of text in it: textAddress.Text = "100 America Avenue, New York, NY...
4
by: shihab | last post by:
I have one multi line text box.i want to 'add text this text box one by one' from database(eg.Customer Name Field).i am using C#.plz give me a solution thanx shihab
4
by: sandeepsangshetty | last post by:
Hi friends, i created one windows form in c#. In that form through 'text box' text i want to add items to the 'list box' with the help of button. Here the problem is 'while entering the items to...
1
by: gorstiedaghost | last post by:
Hi, atm i have a peice of code that will open microsoft word, and then copy text that it inside two speech marks. But instead of copying the text from the speech marks, i want to change the code to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.