Need to remove space from negative value

Posted on 2007-10-08
Last Modified: 2010-04-23

I have a program where a user types in an amount. It works fine, but if they type in a negative value and leave a space in between the negative and the number it blows up. Ex. - 12.94 instead of -12.94.

Is there a way that I can remove, or replace that space. This is my code, and I need it for the txtAmt.text:

 While dtr.Read()
            txtyear.Text = dtr("phone_year") & ""
            txtmonth.Text = dtr("phone_month") & ""
            txtEmployee.Text = dtr("Employee") & ""
            txtNumber.Text = dtr("PhoneNumber") & ""
            txtAccount.Text = dtr("FunctionalAccount") & ""
            txtAmt.Text = dtr("phone_amount") & ""
        End While

I tried to do it like this:

 Dim vAmt = Replace(Trim(txtAmt.Text), "' '", "")
vAmt = dtr("phone_amount") & ""

But I think that the trim removes spaces before and after, not within the text.  If anyone could help me out or lead me in the right direction I would really appreciate it. Thank you.
Question by:savache27
    LVL 35

    Accepted Solution

    use replace function to remove spaces within the text:

    no_space_string=Replace(mystring, " ", "")

    Author Comment

    Thank you so much! I really do appreciate your help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    This video discusses moving either the default database or any database to a new volume.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    779 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

    9 Experts available now in Live!

    Get 1:1 Help Now