-
Jan 11th, 2018, 11:28 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Function to remove leading & trailing spaces in a text box?
Is there a way to write a function that can remove the leading & trailing spaces as well as extra spaces between words as well as in the below example from a Text Box?
spaceVertexspace spaceNospace.space 365 (space22 Pairsspace)
Result: "Vertex No. 365 (22 Pairs)"
I need a function to remove such extra spaces like leading & trailing and in brackets' spaces from a Text Box.
Last edited by VS2013; Jan 11th, 2018 at 11:38 AM.
-
Jan 11th, 2018, 12:03 PM
#2
Re: Function to remove leading & trailing spaces in a text box?
Hi,
what have you tried sofar ?
take a look at Regex Replace
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jan 11th, 2018, 03:57 PM
#3
Re: Function to remove leading & trailing spaces in a text box?
Try this
Code:
Private Function RemoveExtraSpaces(strText As String) As String
Return String.Join(" ", strText.Split({" "}, StringSplitOptions.RemoveEmptyEntries)).Replace("( ", "(").Replace(" )", ")")
End Function
Last edited by 4x2y; Jan 11th, 2018 at 04:03 PM.
-
Jan 11th, 2018, 04:19 PM
#4
Thread Starter
Hyperactive Member
Re: Function to remove leading & trailing spaces in a text box?
-
Jan 11th, 2018, 04:25 PM
#5
Re: [RESOLVED] Function to remove leading & trailing spaces in a text box?
You may also consider replacing "space." with ".", i have just noticed it now!
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
|