Remove character from string in VB6

I have several lines (file paths) that sometimes contain random noise (CRLF) inside them that I have to delete. How can I do it?

+4
source share
3 answers

Take a look at Replace(..) .

 someVariable = Replace(someVariable, vbNewLine, "") 
+11
source

Replace$() is being replaced;

 path = Replace$(path, vbcrlf, "") 
+6
source

This will remove all CRLFs in your line.

 strFileName = Replace(strFileName, vbNewLine, "") 

Here is the function you can put in the helper module:

 Public Function CleanFilePath(FilePath As String) As String Return Replace(FilePath, vbNewLine, "") End Function 

EDIT:

Alternatively, an auxiliary routine is used to modify the string itself. However, this is not standard practice in newer languages.

 Public Sub CleanFilePath(ByRef FilePath As String) FilePath = Replace(FilePath, vbNewLine, "") End Sub 
+3
source

All Articles