-
Jan 16th, 2010, 08:56 AM
#1
Thread Starter
Member
Running total in VB
Hi,
Im trying to keep a running total within a text box. The code I am using is
Code:
RunningTotal.Text = Txtbox1.Text + RunningTotal.Text
WHen I do this, RunningTotal.text only adds the content from txtbox1 onto the end, so I end up with something like " 1.50, 1.50". Every time I hit Add, i just get another 1.5o added onto the end of the existing 1.50, 1.50.
Thanks
-
Jan 16th, 2010, 09:02 AM
#2
Re: Running total in VB
vb.net Code:
RunningTotal.Text = VAL(Txtbox1.Text) + VAL(RunningTotal.Text)
-
Jan 16th, 2010, 09:03 AM
#3
Re: Running total in VB
Those results are correct. + when used with strings is the same as & (concatenate).
Read about TryParse, ToString, and Convert.
-
Jan 16th, 2010, 09:07 AM
#4
Re: Running total in VB
Val would be my last choice, especially for user input.
-
Jan 16th, 2010, 09:10 AM
#5
-
Jan 16th, 2010, 09:24 AM
#6
Thread Starter
Member
Re: Running total in VB
Thanks, Not far wrong! I will read those articles which you published dbasnett.
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
|
Click Here to Expand Forum to Full Width
|