• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Need to remove space from negative value

Hi,

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.
0
savache27
Asked:
savache27
1 Solution
 
YZlatCommented:
use replace function to remove spaces within the text:

no_space_string=Replace(mystring, " ", "")
0
 
savache27Author Commented:
Thank you so much! I really do appreciate your help.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now