|
-
Mar 6th, 2006, 09:14 AM
#1
Thread Starter
New Member
[RESOLVED] help with multiline textboxes
hi,
I'm an engineer who dabbles in programming and i need some help from you all the experts, I need to know how to output several lines into a textbox. what i need to have is a heading, and then several lines (actual no. depending on the user inputs) in one textbox. each line comes from a pass through a loop.
Thanks.
R. Jhilmit
-
Mar 6th, 2006, 09:19 AM
#2
Re: help with multiline textboxes
Welcome to the Forum 
Set the multiline property of the textbox to true.
Set the Scrollbars property to 3-Both.
And whenever you add a line of text to the text box, append it with vbcrlf. Something like this
VB Code:
Text1.Text = "This is the first line" & vbcrlf
Text1.SelStart = Len(Text1.Text)
Text1.SelText = "This is another Line" & vbcrlf
Text1.SelStart = Len(Text1.Text)
Text1.SelText = "This is the third Line" & vbcrlf
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Mar 6th, 2006, 09:25 AM
#3
Re: help with multiline textboxes
Welcome to the forums. 
Another way is
VB Code:
Text1.Text = Text1.Text & vbCrLf
It all depends on which way works best for you.
-
Mar 6th, 2006, 09:25 AM
#4
Re: help with multiline textboxes
or just:
VB Code:
Text1.Text = "This is the first line"
Text1.Text = Text1.Text & vbCrLf & "This is another Line"
Text1.Text = Text1.Text & vbCrLf & "This is the third Line"
Edit: too slow
-
Mar 6th, 2006, 09:29 AM
#5
Thread Starter
New Member
Re: help with multiline textboxes
thanks,
but when i try to implement this in a for loop i only get the 1st line.
For i = 1 To 10
Text1.SelStart = Len(Text1.Text)
Text1.Text = "line" & i & vbCrLf
Next i
i want this to ouput something like
line1
line2
line3
.
.
.
line10
but all it does is show me line10. how can i fix this?
Thanks
R. jhilmit
-
Mar 6th, 2006, 09:33 AM
#6
Thread Starter
New Member
Re: help with multiline textboxes
Thanks a whole bunch, the 2nd way works the way i need it to, that is text1.text = text1.text & "". One last question, is there anyway of entering a tab so that the columns are evenly spaced?
thanks.
-
Mar 6th, 2006, 09:34 AM
#7
Re: help with multiline textboxes
When you use .Text you are replacing the whole text, if you look at my example I am using SelText, so your code should be like this
VB Code:
For i = 1 To 10
Text1.SelStart = Len(Text1.Text)
Text1.SelText = "line" & i & vbCrLf
Next i
PS: Use code tags when you post code.
To insert Tabs use vbTab constant like this
VB Code:
Text1.Text = "Some Text" & vbtab & "More Text" & vbTab & "Some more here"
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Mar 6th, 2006, 09:37 AM
#8
Re: help with multiline textboxes
 Originally Posted by thetruedarknight
Thanks a whole bunch, the 2nd way works the way i need it to, that is text1.text = text1.text & "". One last question, is there anyway of entering a tab so that the columns are evenly spaced?
thanks.
You are dealing with a textbox, not ListView. Even spacing in a free form textbox would require knowing the exact length of whatever will be the longest line + 2 then tabbing that number of spaces after the length of each line minus that length against the longest.
-
Mar 6th, 2006, 09:40 AM
#9
Thread Starter
New Member
Re: help with multiline textboxes
thanks, this works.
So grateful this place exists.
R. Jhilmit
-
Mar 6th, 2006, 09:41 AM
#10
New Member
Re: help with multiline textboxes
Or you can do something like this:
VB Code:
For i = 1 To 10
Text1.Text = Text1.Text & "Line No" & i & vbCrLf
Next i
-
Mar 6th, 2006, 09:44 AM
#11
Re: help with multiline textboxes
 Originally Posted by thetruedarknight
thanks, this works.
So grateful this place exists.
R. Jhilmit
If this is resolved, please pull down the Thread Tools menu and click the Mark Thread Resolved button. That will let everyone know that you have your answer.
Thank you.
-
Mar 6th, 2006, 09:44 AM
#12
Re: help with multiline textboxes
 Originally Posted by thetruedarknight
thanks, this works.
So grateful this place exists.
R. Jhilmit
--removed content-- already posted in previous thread by Hack.
@Hack: I thought I will post this first and I even did, but you are too quick in spamming.
Use [code] source code here[/code] tags when you post source code.
My Articles
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|