DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2006
    Location
    PA
    Posts
    259

    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.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  3. #3
    Join Date
    Aug 2006
    Location
    PA
    Posts
    259
    Quote 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.

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  5. #5
    Join Date
    Aug 2006
    Location
    PA
    Posts
    259
    Quote 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

  6. #6
    Join Date
    Dec 2005
    Location
    South of Nowhere, Maine
    Posts
    309
    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.

  7. #7
    Join Date
    Aug 2006
    Location
    PA
    Posts
    259
    Quote 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

  1. Replies: 5
    Last Post: 06-19-2006, 09:48 AM
  2. SQLServer and empty strings
    By JBird in forum Database
    Replies: 2
    Last Post: 06-09-2005, 04:23 PM
  3. Empty string or nothing
    By Michael Culley in forum .NET
    Replies: 4
    Last Post: 04-26-2002, 02:21 AM
  4. Significance of System.EventArgs?
    By Paul Mc in forum .NET
    Replies: 5
    Last Post: 06-06-2001, 05:10 PM
  5. jsp:setProperty for empty Strings
    By Richard McLaren in forum Java
    Replies: 0
    Last Post: 01-12-2001, 04:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links