Solved remove commas at end of address if not all fields are entered

Posted on 2012-09-07
Last Modified: 2012-09-10
I have to concatenate 5 fields into one string to create an address that is entered into one field in a database.  When not all of the fields are entered, I get commas at the end of the string, i.e. "555 North Ave, , , "   How can I removed these before saving?  It is not a matter of saving to different fields...I am working with old code and old tables that already have thousands of addresses that were saved to one field and I cannot change that.  I also cannot require all address fields have data.  I just want the save to the one address field as clean as possible.   Thanks for your help in advance.
Question by:McGurk1
    LVL 85

    Accepted Solution

    You can do:

        str = str.TrimEnd(",")

    Author Closing Comment

    Thanks for the help.  This does only get rid of the last ","  but is heading in the right direction.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now