-
deleting empty strings
Hi can someone give me a hand on figuring out how i would delete the empty strings from the end of a string? currently I've built a function that builds a query based on user input , the thing is that it will add empty strings to the rest of the query if they dont pick certain things . The number of empty strings and length of the string is unknown because it depends on the user and what they pick. heres an example of what I need to do : lets say based on user input , my function ends up with a query string like : "Select field1,field2,field3 from tablea,tableb where field1 = field2____________________________________" (all that space at the end is what I need to get rid of)
Im working on it currently but it would be nice if someone could also help me look into this while I'm at it. I know theres functions to delete strings but since my case is not that simple it's gonna take a little thought to figure this one out.
Last edited by Matrix.net; 10-13-2006 at 10:01 AM.
-
Try this: In Visual Studio, declare a string variable and assign it a value with several spaces at the end:
Code:
Dim MyString As String = "x "
Now, on the next line, type the name of the string variable (MyString), followed by the period character (.); you'll see a dropdown list of the actions you can perform on that variable. Scroll through the list and see if one of them looks useful. ;-)
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
 Originally Posted by Phil Weber
Try this: In Visual Studio, declare a string variable and assign it a value with several spaces at the end:
Code:
Dim MyString As String = "x "
Now, on the next line, type the name of the string variable (MyString), followed by the period character (.); you'll see a dropdown list of the actions you can perform on that variable. Scroll through the list and see if one of them looks useful. ;-)
thanks but like I said above I already did that. The problem isnt deleting the blanks, its trying to figure out at which point in the string there is nothing but blanks and then delete from that point till the last blank/empty string is deleted.
-
Did you try MyString.TrimEnd?
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
 Originally Posted by Phil Weber
Did you try MyString.TrimEnd?
I didnt try it because the description didnt sound like it was what I needed. Maybe you can give me a clearer explenation of what it does? Thanks
-
Try the help file on TrimEnd.
It trims all blankspace from the END of the string (leaving any blankspace in the front or middle of the string alone.
-
 Originally Posted by edburdo
Try the help file on TrimEnd.
It trims all blankspace from the END of the string (leaving any blankspace in the front or middle of the string alone.
thanks, I resolved the issue last night though. It just had to do with me not having single quotes around certain things and having them around things I shouldn't . I will make a note of that however.
Similar Threads
-
By Miha Markic in forum .NET
Replies: 5
Last Post: 06-19-2006, 09:48 AM
-
By JBird in forum Database
Replies: 2
Last Post: 06-09-2005, 04:23 PM
-
By Michael Culley in forum .NET
Replies: 4
Last Post: 04-26-2002, 02:21 AM
-
Replies: 5
Last Post: 06-06-2001, 05:10 PM
-
By Richard McLaren in forum Java
Replies: 0
Last Post: 01-12-2001, 04:47 AM
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks