ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   VB TRIM$ question (https://www.scoobynet.com/computer-and-technology-related-34/133250-vb-trim-question.html)

Scotty Boy 19 September 2002 03:35 PM

Hi All,

Does anyone know of a command that like TRIM$ removes spaces, will remove spaces AND tabs ???

I have not chosen REPLACE because i only want to manipulate the left and right of the string NOT anything in the middle.

My search proved a failure and as such i have written a loop that performs the job, but my curiosity has got the better of me and i want to know as to whether there is a command like REMOVE_ALL_WHITE_SPACE ??????

thanks scott :D

David_Wallis 19 September 2002 03:39 PM

can you not use substr or Left$ Right$ or similar...

otherwise I think you would have to do a loop and move through the string until you find chr(10) Or whatever..

David

Scotty Boy 19 September 2002 03:46 PM

Hi David,

The problem with LEFT$ or RIGHT$ is that i dont know where to start, there might be 1 .. 2 .. or 9 spaces or tabs.

So now i am back to my loop. I am still searching for that
REMOVE_ALL_WHITE_SPACE$(the_string) :D command

David_Wallis 19 September 2002 04:46 PM

right then write it as a function called removeallwhitespaces(x as String)

then just do removeallwhitespaces("Test Blah")

:D

David

Scotty Boy 19 September 2002 04:53 PM

Yep that is bascially what i have done :)

but my REMOVE_ALL_WHITE_SPACE(string) uses a loop blah blah blah

i wanted an internal VB method to use - just being lazy. well actually not really lazy - i have written my own method and both you and i are spending time trying to find an internal VB method for this.

Thanks for your advice

scott :D

Scotty Boy 19 September 2002 05:06 PM

a collegue just blasted this out - totally forgot about the regular expressions !!!

Dim regEx As VBScript_RegExp_55.RegExp
Dim str As String

Set regEx = New VBScript_RegExp_55.RegExp

str = " " & vbTab & " ab " & vbTab & "cd " & vbTab & " "

regEx.Pattern = "\s+$"
str = regEx.Replace(str, "")

regEx.Pattern = "^\s+"
str = regEx.Replace(str, "")

MsgBox str


All times are GMT +1. The time now is 10:12 PM.


© 2024 MH Sub I, LLC dba Internet Brands