473,394 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Question on TRIM function

Can someone please explain this to me

Dim str As String = Chr(12)
Debug.WriteLine(str) ' Output shows the line feed junk character

Dim iLen As Integer = str.Trim.Length
Debug.WriteLine(iLen) ' Output window shows 0

Dim iLenNoTrim As Integer = str.Length
Debug.WriteLine(iLenNoTrim) ' Output window shows 1

I thought Trim removes all leading and trailing spaces. I didnt understand
why Trim removes CHR(12).
CHR(12) is a line feed character

TIA

--
Wazir

Nov 20 '05 #1
6 1416
Hi

I do not know if you use ms.visualbasic...Trim or String.Trim. I'm not sure about ms.visualbasic...Trim
but System.String.Trim removes all white spaces. White spaces include characters like tab formfeed (chr(12)
cariage return (13) line feed (10) and so on.

Hope it help

Greating

Ras Alhague
Nov 20 '05 #2
"mwazir" <mw*******@vsnl.com> schrieb
Can someone please explain this to me

Dim str As String = Chr(12)
Debug.WriteLine(str) ' Output shows the line feed junk
character

Dim iLen As Integer = str.Trim.Length
Debug.WriteLine(iLen) ' Output window shows 0

Dim iLenNoTrim As Integer = str.Length
Debug.WriteLine(iLenNoTrim) ' Output window shows 1

I thought Trim removes all leading and trailing spaces. I didnt
understand why Trim removes CHR(12).
CHR(12) is a line feed character


Have a look at the Trim documentation (the one without args): All chars are
removed where char.IsWhiteSpace returns True. See char.IsWhitespace docs on
what chars are "white spaces".
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #3
I am using System.String.Trim

Thanks for your response. I was under the impression that its only the
trailing and leading spaces.

Regards
--
Wazir
"Ras Alhague" <an*******@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
Hi,

I do not know if you use ms.visualbasic...Trim or String.Trim. I'm not sure about ms.visualbasic...Trim, but System.String.Trim removes all white spaces. White spaces include characters like tab formfeed (chr(12)) cariage return (13) line feed (10) and so on..

Hope it helps

Greatings

Ras Alhague

Nov 20 '05 #4
* "Armin Zingler" <az*******@freenet.de> scripsit:
Have a look at the Trim documentation (the one without args): All chars are
removed where char.IsWhiteSpace returns True. See char.IsWhitespace docs on
what chars are "white spaces".


'Char.IsWhiteSpace(Chr(12))' returns 'True' on my system.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
* "Armin Zingler" <az*******@freenet.de> scripsit:
Have a look at the Trim documentation (the one without args): All
chars are removed where char.IsWhiteSpace returns True. See
char.IsWhitespace docs on what chars are "white spaces".


'Char.IsWhiteSpace(Chr(12))' returns 'True' on my system.


Yes, that's why it is removed.
--
Armin

Nov 20 '05 #6
* "Armin Zingler" <az*******@freenet.de> scripsit:
Have a look at the Trim documentation (the one without args): All
chars are removed where char.IsWhiteSpace returns True. See
char.IsWhitespace docs on what chars are "white spaces".


'Char.IsWhiteSpace(Chr(12))' returns 'True' on my system.


Yes, that's why it is removed.


Ooops. While reading your post I forgot that length actually /was/ 0
after trimming...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: asdfkajsdflkjsadlfkjoewqifoeiwjf | last post by:
Hi Im using php to parse an xml file of below format. I have no problem extracting the various values within the tags (lib, id, url, file etc), but cant get hold of whats in the tag (max_page,...
12
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the...
23
by: David Frank | last post by:
How can I write a string function that encloses the input string in quotes "string" ?? below works for the "123 operation but adding " to it clobbers the "123 main() { char...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
7
by: Sascha Herpers | last post by:
Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two...
2
by: Maciek | last post by:
I've got this question regarding programming practices. I'm designing Newsletter module in my WebApp and I'm greenhorn in programming. There's a stored procedure which adds a subscriber to a DB. It...
4
by: Oleg Subachev | last post by:
If I apply Trim() method to string consisting of two x0D and x0A characters the resulting string is not empty but contain the same two charaters: x0D, x0A. But according to the help Trim()...
12
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I trim whitespace - LTRIM/RTRIM/TRIM?...
5
by: Marjeta | last post by:
I'm trying to very that the user actually entered something in the form, and not just spaces. I guess the problem is in the first line of isBlank() function. I've tried the following:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.