-
Jun 27th, 2008, 09:15 AM
#1
Thread Starter
New Member
new line in rich text box
Guyz,
i got a problem here,
actually, it is pretty simple.
i want to insert a new line in richtextbox by using the VB programming code.
for example,
i have richtextbox1 and command1,
and i make this code :
private_sub command1_click
richtextbox1.text = "abcdefghijk" & "lmnopqrstu"
end sub
the result when command1 is clicked :
abcdefhijklmnopqrstu
what i want is to put the "lmnopqrstu" on the next line, like this :
abcdefghijk
lmnopqrstu
can anyone help ?
i know it is pretty simple, but i need the answer,
please reply...
-
Jun 27th, 2008, 09:17 AM
#2
Thread Starter
New Member
VB version
one more thing,
im using Visual Basic 6.0.
Thanks !
-
Jun 27th, 2008, 09:39 AM
#3
Re: new line in rich text box
Welcome to VBForums
I would use the vbNewLine constant, eg:
Code:
richtextbox1.text = "abcdefghijk" & vbNewLine & "lmnopqrstu"
-
Jun 27th, 2008, 09:41 AM
#4
Re: new line in rich text box
If you are adding a new line to existing text, then do
Code:
RichText1Box.Text = RichTextBox1.Text & "Here is the new line of text" & vbNewLine
-
Jun 27th, 2008, 11:55 AM
#5
Fanatic Member
Re: new line in rich text box
I would have suggested vbCrLf. Is there a difference?
-
Jun 27th, 2008, 12:00 PM
#6
Re: new line in rich text box
Both accomplish the same thing.
-
Jun 27th, 2008, 12:20 PM
#7
Fanatic Member
Re: new line in rich text box
-
Jun 27th, 2008, 01:22 PM
#8
Re: new line in rich text box
In theory vbNewLine is platform specific (so for Mac/Unix would use a different character combination), but that isn't relevant to VB.
I prefer vbNewLine as it is easier to read/remember.
-
Jun 27th, 2008, 01:23 PM
#9
Re: new line in rich text box
Not that it matters, but I typically use vbCrLf because it is less characters to type.
-
Jun 27th, 2008, 01:24 PM
#10
Fanatic Member
Re: new line in rich text box
ah so it's similar to locales and keyboard maps in terms of expandability?
-
Jun 27th, 2008, 01:30 PM
#11
Re: new line in rich text box
If you run code on Windows (which is all VB allows), vbNewLine is exactly the same as vbCrLf.
On a Mac or Unix (so could only be VBA, perhaps in Office), it becomes whatever combination of characters is used on those OS's to indicate a new line... which may be just vbCr or just vbLf.
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
|