Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Difference Between VbCrLf And VbLf

Ok, i'm encountering some problem with the use of VbCrlf (Carriage Return LineFeed Combination) with my richedit control, as an alternative, i plan to force my RichEdit control to use VbLf (linefeed, chr(10)) using code, whenever the user presses the "ENTER" key on their keyboard

The end result is that i get less error with VbLf and my app have no error anymore, i notice there's not much difference between the two as well, but just for safety's sake , can anyone tell me the difference between them?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Hi people, I have a simple question. Is there any function like TRIM wich i can get a clean string without vbCrLf,vbLf,vbCr?
Sorry my english. Thanks in advance. Bye!

VbCrlf, VbCr, VbLf
What do vbCrlf, vbCr and vbLf do? Please inform this rookie!!!

Check If File Has Vbcrlf Or Vblf
Hi guys!

How can I know if a file has any of these vbcrlf or vblf characters?

Based on that result, I would process the files.......Otherwise, if I anticipate that I get a good file all the time...then I am screwed, as it happened today....

Can anyone tell me?

RichtextBox Vbcr - Vblf - VbCrlf Problem
Hello !
I am using a richtextbox . The problem things that strange problems happen with vbcr , vblf , vbcrlf.
I load into the richtextbox a file that is a webpage source.
This webpage can also have been written in unix etc. with no
windows standard line feed character.

I do instr("mytext") and get a value 10 for example
the problem is that because of vblf is not counted as a character or something like that when i do richtextbox.selstart=10
instead of going to the "mytext" it goes much after or before the position of "mytext".

What is the windows standard character for line feed?
Should i replace vbcr and vblf with vbcrlf in the beginning ?

thanks !

VbCrLf And VbLf Comparison In Text File.
Hello there, everybody?

I have two text files. One was generated under windows so "vbCrLf" is as newline break for each line.
The other one is generated under *NIX OS so "vbLf" is used.

Both files have the same format except for the "vbCrLf" and "vbLf".

How could I distinguish those two?
Suppose that each line has a length of 30 characters exactly with no exception.
I've tried
delimiter = vbCrLf
''' used 31 because each line contains 30 chars and 31st character is the newline character
if (strcomp(right(input(31, fh), 1), vbLf, vbTextCompare)) then
  delimiter = vbLf
end if

I've also tried "vbBinaryCompare" for the above comparison but I have been fruitless.
I would appreciate your kind helps

Edited by - dance2die on 6/1/2004 11:14:12 AM

Qs: Difference Between VbCrLf V.S. VBNewLine
I would like to know the difference between vbCrLf V.S. VBNewLine!
vbCrLf V.S. VBNewLine?!
What is the difference in these ways?
Very thanks.

Parsing Http Response From Winsock.. (not As Easy As Split(data,vbcrlf + Vbcrlf,2))
How can I get the response from a http response?
Its not as simple as split(data,vbcrlf + vbcrlf,2)).

Although this code will split the headers from the response, the response still has some data seperating the response from the content.

For example:

HTTP/1.1 200 OK
Date: Tue, 15 Aug 2006 04:21:21 GMT
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
Set-Cookie: B=2tu47kd2e2iu1&b=3&s=bo; expires=Tue, 02-Jun-2037 20:00:00 GMT; path=/;
Set-Cookie: Y=%2e; expires=Thu, 15 Apr 2010 20:00:00 GMT; path=/;
Set-Cookie: T=z=0; expires=Thu, 01 Jan 1970 22:00:00 GMT; path=/;



as you can see, theres a lot of line feeds in there, along with '488e' for example. there is also some data at the end that is not content. for example

</script><noscript><img width=1 height=1 alt="" src=""></noscript></html>


Note the 0 there with additional line feeds. you might think looking though the response and assuming that the content begins at a "<" will signify the start of the content, and the last ">" signifies the end, but this will not work if the content retrieved is an image, or gzip content, etc.

So.. how can you get the content from the response?
Is there a standard for this?

How To Determine Constant, Such As VBLf
I hope this is simple for some of you.
I had a problem with some data and I was trying to determine what the hex value was. In a text file, I had vbLf text data instead of vbCrLF codes. I couldn't determine what the code was because all of the conversion routines would fail with 'run-time error 13'.
Even the Hex function failed. I finally found out is was vbLf bystepping through multiple If statements checking for each of the VB constants in the Object Browser Constants description.
So, in the future when I get a run time error 13, I would like to be able to see just what is the hex value of the code that is failing. What utility is available to do this?

Replacing Vbcr And Vblf With Another Character?
Is it possible to replace vbcr and vblf with another character, if so how? I can't use Instr to locate where those lf's are

Difference Between ScaleHeight And Height,difference Between CurrentX And CurX?
Hi Can any one explain me briefly about Difference between scaleHeight and Height,difference between CurrentX and CurX?

I am always confusing.


Difference Printer Give Difference Display
I have problem here. If I use and set Microsoft Office document image writer as printer, it works find, The output and its position is acceptable. If I set the Canon as printer, The size of output result become larger. Why it would be like this?I use same code to print out the document. And I have only one print, but I can print out the paper using both printer type.

Form5.MapCompactMaps.OutputMap2 Printer.hDC, 300, 400, 5000, 5000

Hi every one i am just trying to make the text in my game stay there and then carry down a line every round and this works in one of my programs with a text box but won't work now, any ideas?
txtText.Text = txtText.Text & vbCrLf & Attack(Int(Rnd * 20 + 1))

VbCrLf ????
I have an in class project, I need to use vbCrLf to put the text from two different texboxes on different lines. Where and how do I put this in my code??

Private Sub cmdDisplay_Click()
'Display text from txtName and txtMessage in lblMessage
lblMessage.Caption = txtName.Text & ": " & txtMessage.Text
lblMessage.FontSize = (12)

End Sub

A quick responce would be helpful
Thank you

What Is VbCrLf
The constant vbCrLf returns a carraige return and a line feed, what are these?

IIF And VbCrLf
OK. I figured out how to get the IIF statements to work for my change machine however now that I've added the IIF statements in I don't see the results displayed in the text box for all the coins, only one of them. Before I added the IIF statments I had the vbCrLF at the end of each line to display each of the coins one after the other in the text box and it always worked.

Any suggestions.

&amp; Vbcrlf
Hello there

i don't know what i'm doing wrong, but i have a line of code not working...

The line in question is:

frmPrint.text1.text = "Line One" & vbCrLf & "Line Two"

Is it my coding, or is it VB? How else do i get a new line?


- Adam

I have a string (myVar="my text phrase 1 ◄ my text phrase 2"

not that the "◄" represents a CrLf. when I display the string in a text box, it displays "my text phrase 1 ◄ my text phrase 2".
| my text phrase 1 ◄ my text phrase 2 |

Is it possible to get the textbox (multiline) to display the actual CrLf?


| my text phrase 1 |
| my text phrase 2 |


I have a document written in note pad. I know that there are begining of new lines in it but VBcrLf does not seem to detect it. Is there another way of doing that.

&amp;vbcrlf Help
im trying to make a prog where basically it will drop it to the next line i.e

Private Sub Command1_Click()
Dim aimchatwnd As Long
Dim wndateclass As Long
Dim ateclass As Long

aimchatwnd = FindWindow("aim_chatwnd", vbNullString)
wndateclass = FindWindowEx(aimchatwnd, 0&, "wndate32class", vbNullString)
wndateclass = FindWindowEx(aimchatwnd, wndateclass, "wndate32class", vbNullString)
ateclass = FindWindowEx(wndateclass, 0&, "ate32class", vbNullString)
Call SendMessageByString(ateclass, WM_SETTEXT, 0&, Text1.Text "" & vbCrLf ""& Text2.Text"")
If ateclass = 0 Then
MsgBox "Error: Cannot find window"
Exit Sub
End If
Any Body have any ideas thanks

If I use the vbCrLf in a msgbox I noticed that it alignes the words on the left. For example :

VB Code:
MsgBox "This" & vbCrLf & "is" & vbCrLf & "a" & vbCrLf & "test"

Shows lke this :


Can I align them in the center or to the right?


What Does VbCrLf Do?
I trird searching the MSDN Library, but didn't find it.

VbCrLf ??
Can somone explane what this is/does?

What is vbCrlf and what does it do?

VbCrLf Anyone...
I've searched the forums and seen this one before - though not with a satisfying answer... For the moment (?), this does NOT work in an app of mine -


When pouring ot the result in a listbox, the vbCrLf is very much present in the shape of two squares (Ascii 13 and 10 I know).

vbTexCompare - same thing
(Chr(13)+Chr(10)) - same thing

The VBA type library is OK and referenced as it should be, so WHY, WHY, WHY?

There must be a nifty and foolproof way for the utterly ultra-banal task of ridding the contents of a textbox from carriage/linefeed!?! Or MUST I hit it with TWO replaces..?

Regards everybody /lazy lumen

In a lot of posts now I have seen vbcrlf used (I even just told digisenze to use it), Iím not familiar with this and am curious how it is different from vbnewline. Any explanation of this would be appreciated.

Does anyone know how to put a carrage return for the default text for a text box?

I tried this:

Private Sub form_load()
txtHeader.Alignment = 2
txtHeader.Text = "Welcome to the Manager Functions" & vbCrLf & EmployeeName(J)
End Sub

it didn't work. The vbCrLf. Am I doing it wrong??


VbCrLf- Help!
I have successfully removed all the vbCr's from my text file (my program is writing to a txt file) but there's one last vbLf, which I'm unable to remove. It shows in the last line of every file. I'm ending each Print statement by chr$(13) but even if I end the last with chr$(10) it still doesn't remove the vbLf character. Please help GURUS!

What Does VbCrLf Do,
Just trying to learn what it does, Also any other related commands

Hi there! Below is my code for displaying the multiplication tables of 2 to 12.
But although the values are correct and all listed out, there's some strange characters in between, and I believe it's cos' of the 'vbCrLf' thing.
Hope you can help. Thanks!

private Sub Form_Load()

Dim nIndex as Integer, nIndex2 as Integer
Dim strText as string

for nIndex = 2 to 12
for nIndex2 = 1 to 12
strText = strText & nIndex & " * " & nIndex2 & _
" = " & nIndex * nIndex2 & vbCrLf
next nIndex2
next nIndex

Text1.Text = strText

End Sub

If you think that the code examples found in programming books are tough, then try creating a real-world commercial software program. Afterwards, I assure you that you'll be grateful to the code shown in these books.

"No good knight ever dies without saying good-bye to his sword, and no good coder will ever depart without bidding farewell to his programming language. And I, will never die without kissing the blade of my sword, C++." - Xeon

Not Interpreted As Vbcrlf

I'm working on a program that opens a textfile from inet, then writes it to a file on the local harddisk. After this I want to read the data in a textfile ... Everything works, except the fact that the /n (or
) isn't read as a vbcrlf (or a hard enter)... What am I doing wrong, prolly the filetype or something

be reminded that I eventually want to cut the file in pieces using split and stuff them in arrays (simple kinda database alike)

Thnkx for helping!

Remove All Vbcrlf's
How can i remove all enter chars in a textbox. The thing is, the textbox contains the source of a web. But instead of a vbcrlf after the end of a line i see some little square in the textbox. I want to replace this with a normal vbcrlf but how can i do this?

Faulty VbCrLF

Whenever i use vbCrLf in a textbox i get two dark, bold pipe symbols instead of the data being moved to the following line. Does anyone know how this can be solved?


VbCrLf In Richtextboxe's
I tried the following but it didn't work. How exactly to I break a line in a RTB? Everytime I display the string I want, It just over writes the one before it and never scrolls,

With txtMain
.Text = EmoText & vbCrLf
.SelStart = 0
.SelLength = emoLength
.SelColor = vbMagenta
End With

How Do I Replace With VbCrLf?
I have a text document that uses
for new lines instead of vbCrLf. If I try to Replace(Var,"
",vbCrLf) then it finds nothing as these are not real string elements. Is there some way I can do this?



TextBox And VbCrLf
Maybe someone can help me with a small problem,

I have a textbox I use to add text to from a listbox
like this:

If Text3.Text = "" Then
Text3.Text = List2.Text
Text3.Text = Text3.Text & vbNewLine & List2.Text
End If

I want to detect if there is a Line feed or space at
the end of the text in the textbox and if there is I'd
like to remove it....
Is there a way to do this? and how?

Save The VbCRLF's ?? HELP
hi! im doing a html ediotor, and when i save my html, and open it.. the text all comes in one row? WHY! i wna't it to be as a saved it..


this is the code im using to save:

CommonDialog1.Filter = "HTML Files (*.html)|*.html|HTM Files (*.htm)|*.htm)"
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Output As #1
Print #1, RichTextBox1.Text
Close #1
End If

VbCrLf Question.
I have a text box that contains an address value such as

Brian Wilson
123 Harper Way
Some city, Florida

I want to take this this value and put it into an Excel cell as is. Right now when I import this value into Excel it look like this:


How do I get around this?

Replace Vbcrlf's
what i want to do is first, search the text to find the semi-colon ( ; ), then i want to replace all the vbcrlf's AFTER the semi-colon with "", nothing.

this is the code i am using:

Dim start As Long
Dim t As String
t = txttext.Text
If InStr(1, txttext.Text, ";") <> 0 Then start = InStr(1, txttext.Text, ";")
txttext.Text = Replace(t, vbCrLf, "", start - 1)
but when it runs it replaces everything before the semi-colon with "" not after. if i set start to 1 then it works fine, but then it replcaed the vbcrlf's that i wanted too

A Vbcrlf Question
I need help with an Access form. I'm using vbcrlf to insert text randomly selected from Combobox1 as a list in Textbox1. It works fine, but everytime I go back to Textbox1 all of the contents have the focus.

I know I can change this under Tools, Options, but I want to know if there is a vb command that will position my cursor at the end of the last entry in textbox1 whenever it has the focus?

Here's my code:

Private Sub Combobox1_AfterUpdate()
Me.Relationship = Me.Combobox1 & vbCrLf
End Sub

Thanks for your help.

Combine Add [ ] , And VbCrLf
I want to combine and add it in the textbox.. For information I want to show vbCrLf in the textbox not adding new line. The problem in the findlabel text. I don't manually but the listbox items always changing.. How I can code for FindLabel text?


Dim n As Long
TextBox7.Text = ""
For n = 0 To ListBox2.ListCount - 1
TextBox7.Text = TextBox7.Text & "[" & ListBox2.List(n) & "]"
If n <> ListBox2.ListCount - 1 Then TextBox7.Text = TextBox7.Text & ", "
Next n
TextBox7.Text = "Function FindLabel ( " & TextBox7.Text & ")" & vbCrLf & _
"FindLabel = [code] & vbCrLf & [N] & vbCrLf & [name]" & vbCrLf & _
"End Function"

How To Add &amp; And VbCrLf In The Textbox
I have listbox, see the attach files, I want to show in the textbox like this.. when I click at the command button.

[code] & vbCrLf & [N] & vbCrLf & [name]

Need Some Help With VbCrlf And Telnet
Ok I am making a telnet client... and I have it working...

Basicly I get a space in between every command I send....

for example...

I enter the command "pl" after I connect... and I get some data

so I get


but if I enter a new command I will get this



I want it to be on its own line just like the microsoft telnet client does...

I have tried to trim but this doesnt seem to work either...

here is my code...

Private Sub LogText(rtfBox As RichTextBox, strData As String, strcolor As String)
On Error Resume Next
With rtfBox
.SelStart = Len(.Text)
.SelColor = strcolor
.SelText = strData & vbCrLf
.SelStart = Len(.Text)
End With
End Sub
Private Sub Form_Load()
Winsock1.Connect ipaddress, ipport
End Sub
Private Sub Form_Resize()
On Error Resume Next
text1.Width = Form1.Width - 115
text1.Height = Form1.Height - 800
Text2.Width = Form1.Width - 115
Text2.Top = Form1.Height - 790
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 13: If Len(Text2.Text) > 0 Then Winsock1.SendData Text2.Text & vbCrLf: Text2.Text = "" Else Exit Sub
End Select
End Sub
Private Sub Winsock1_Connect()
LogText text1, "Connected to: [" & Winsock1.RemoteHost & ":" & Winsock1.RemotePort & "]", &HFFFFFF
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim data As String
On Error Resume Next
Winsock1.GetData data, vbString
LogText text1, data, &HFFFFFF
RTrim text1.Text
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
text1.Text = "Error Number " & Number & " " & Description
End Sub

Is It Possible To Have VBCrLf In A Constant
I am trying to have a constant which contains the body an email message.
The email message is on several lines.

I have tried using

VB Code:
Public Const message as String = "the first part of the message" & VbCrLf & "the second part of the message" & VBCrLf & "the third part of the message"

what is happening is that the message appears on one line

Any ideas how I can get around this or is there a different way i can store the message. The message is to be used for a letter too so that's why o thought about putting it in a constant

VbCrLf &amp; VbNewLine Not Doing Their Job
I am writing a simple chat program for my own use in a programming class I am taking. It is way more advanced than anything we are going to learn but I decided to do it for fun. I will post the entire program as it isnt much. The problem is when the messages are printed to the text box they come up like this

||Baked: Hi||Host: Hi

When a person talks it doesn't go to the next line.

VB Code:
Dim Nick As StringDim Data As StringDim Data2() As StringDim Port As Single Private Sub cmdChangePort_Click()' I also looked at this from another chat program I know it has something to do with errors'On Error Resume Next' This is the actual routine for changing the port'Port = InputBox("Enter a new port I would suggest anything above 5000")If Port = 0 ThenPort = 5555ElseIf Port < 1000 Then' We Will tell them nicely its not a good idea but they can still do it :)MsgBox (" I don't think it should be lower than 5000 but hey it's your network ")End IfEnd Sub Private Sub cmdConnect_Click()' If the user clicks connect we need a server address 'HostIP = InputBox(" Enter The Server Address ")ws1.Connect HostIP, PortEnd Sub Private Sub cmdHost_Click()' This is the winsock command to listen or host 'ws1.LocalPort = Port' Listen for the incoming connections 'ws1.ListenMsgBox (" Host Created ")End Sub Private Sub cmdSend_Click()' This is going to be where we actually send the data it is split into two parts, the nickname and the actual text to send to the host 'ws1.SendData Nick & "~!@#" & txtSend.Text' This line updates the chat room with your message you just sent and in case you didn't know'' The vbCrLf stands for visual basic Character Return and Line feed which is basically enter and a new line 'txtChat.Text = txtChat.Text & vbNewLine & Nick & ": " & txtSend.Text'Erase the text you just entered so you don't have to do it manually 'txtSend.Text = ""' You might just have erased the text but you need to focus back on the box so you can type again 'txtSend.SetFocus' This line I took out of somewhere else but it has something to do with keep the scroll bar at last line typed 'txtChat.SelStart = Len(txtChat)End Sub Private Sub Form_Load()' Make sure there isn't anything in the text box 'txtSend.Text = ""' Display the Nick 'Nick = lblCNick.Caption' Assign the default port 'Port = 5555End Sub Private Sub lblCNick_Click()' When the user clicks this he/she will be able to change their nick 'Nick = InputBox("Enter A New Nick")' This is a check to make sure the Nickname isn't longer than 10 Characters it gets messy if any longer 'If Len(Nick) > 10 Then' Change the Nick back to NoName if they enter more than 10, this also serves as a buffer overflow protection 'Nick = "NoName"' A message box saying the nick was too long 'MsgBox "Please Enter A Nick Shorter Than 10 Characters"End If' Update the caption for the label 'lblCNick.Caption = NickEnd Sub Private Sub mnuAbout_Click()frmAbout.ShowEnd Sub Private Sub mnuExit_Click()EndEnd Sub Private Sub mnuGetIP_Click()MsgBox " Your IP Address is : " & ws1.LocalIP & " "End Sub Private Sub txtSend_KeyUp(KeyCode As Integer, Shift As Integer)'This occurs when the user pushes a button ''vbkeyreturn simply means enter 'If KeyCode = vbKeyReturn Then'do same as if the user clicked cmdSend , a.k.a. Send 'Call cmdSend_ClickEnd IfEnd Sub Private Sub ws1_DataArrival(ByVal bytesTotal As Long)'if we get data from someone this is what we do'ws1.GetData Data, vbString, bytesTotal' here we split what we received seperate the buffer from the actual data 'Data2() = Split(Data, "~!@#")'print the real data'txtChat.Text = txtChat.Text & vbNewLine & Data2(0) & ": " & Data2(1)'once again the scrolling issue'txtChat.SelStart = Len(txtChat)End Sub Private Sub ws1_ConnectionRequest(ByVal requestID As Long)' This is to make sure Winsock isnt stuck when you open the program 'If ws1.State <> sckClosed Then ws1.Closews1.Accept requestIDEnd Sub

How Do I Replace With VbCrLf?
I have a text document that uses
for new lines instead of vbCrLf. If I try to Replace(Var,"
",vbCrLf) then it finds nothing as these are not real string elements. Is there some way I can do this?



VbCrLF And Labels
Is there anyway I can put a vbCrlf in a label at design? thanks

VbCrLf Vs VbNewLine
What is the diffrence between vbCrLf and vbNewLine?
I know they are breaking the text and making a new line. Are they doing other things?

ToolTipText And VbCrLf
Can I use vbCrLfs in a ToolTip? I tried doing it, but it just showed the [][] characters, from the chr(13) & chr(10). How can I actually get a return in there?


Deleting VbCrLf
During my usage of RichEdit (again hehe), when i press backspace or the delete key to delete a vbCrLF aka carriage return line feed, or new line, well the line is deleted, meaning that i can't move to that line anymore when i press the arrow key or clicking on that part.

Now i want to mimic the samething using the codes, i've tried selecting them and assigning "" (nothing ) and tried invoking the richedit_keydown event .

The end result is, my pointer performs the delete act as intended, however, one difference is that the the code statement can't remove the vbCrLF, meaning that i can still move my cursor to that line, what i want to do is to be able to fully terminate that line, at runtime, using code, is this possible?

Copyright © 2005-08, All rights reserved