473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to add Multiple textbox values as they are updated?

110 100+
I have a several text boxes available on a form. At the bottom of the form there is a disabled text box for the total. I currently can add all the values upon a button click, however I would like to, if possible, make it so as a form is filled in, the total adds within the total text box.

I thought maybe something like:
Expand|Select|Wrap|Line Numbers
  1. txtbxTotal.text = txtbxTotal.Text + (list of other text boxes)
  2.  
I am running into two issues, I don't know how if at all I can code it to increment in real time as the fields are updated, and I also don't know how to do something like a try parse when I am accepting decimal values.

Any help with either problem are greatly appreciated.
Jan 8 '11 #1
3 6268
Fuzz13
110 100+
With regards to adding the values of decimals and verifying that they contain only numbers and a single decimal, I call a try on my method that adds the values, and a catch on the format error exception and that allows me to make sure it is acceptable numbers being used.

Still need help with the live update in the total text box though.
Jan 9 '11 #2
GaryTexmo
1,501 Expert 1GB
There is an event on a TextBox called TextChanged...

http://msdn.microsoft.com/en-us/libr...xtchanged.aspx

You can create a handler for this event where you call a method that will check to see if the textboxes have values... if they do, they enable the total and then perform the calculation, otherwise it disables the total text box.

For parsing doubles, you can use the TryParse method available on the double type.

http://msdn.microsoft.com/en-us/library/3s27fasw.aspx
Jan 10 '11 #3
Fuzz13
110 100+
Awesome. This is what I ended up with in case anyone in the future wants an example:

Expand|Select|Wrap|Line Numbers
  1. private void txtbxOnes_TextChanged(object sender, EventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 AddValues();
  6.             }
  7.             catch (FormatException)
  8.             {
  9.                 //do nothing
  10.             }
  11.         }
  12.  
Expand|Select|Wrap|Line Numbers
  1. if (txtbxOnes.Text == "")
  2.                 ones = 0;
  3.             else ones = Convert.ToInt32(txtbxOnes.Text);
  4.  
  5. txtbxTotal.Text = ones; //and then whatever other text box values are needed.
  6.  
Thanks textmo

I will look at the tryparse for doubles, I ended up using a try catch on the addvalues() method that catches a format error that gets kicked up if a letter or symbol is used.
Jan 10 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
2
by: Newbee Adam | last post by:
how to save textbox values to 2 tables using sqladapter I am new with this. Do I need to ADO.net? what is the simplist correct way? or can I write a query in my vb.net form insert table...
4
by: cwwilly | last post by:
Hello, Thanks for taking a look at this! Problem: I'm trying to pass multiple dynamic values between a slaveform and a masterform. The problem I'm having is on the slaveform I loop through...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
4
by: bwalke | last post by:
I am developing a web form which is going to be used for manufacturing input. The form uses a DataList which list a batch of parts that may range anywhere from 1-9 parts. The DataList contains 6 ...
8
by: aleksandar.ristovski | last post by:
Hello all, I have been thinking about a possible extension to C/C++ syntax. The current syntax allows declaring a function that returns a value: int foo(); however, if I were to return...
1
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i...
0
by: sandhyamn | last post by:
hi....i am writing a jsp code for uploading file inside a folder using multipart/form-data.but also i want to write textbox values in to that file, but the textbox values is not coming. ie..textbox...
1
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime =...
9
by: kumarrk | last post by:
Hi all, i am using place holder for dynamic textbox and label box, then when i enter the values in textbox then i click the add button and save to database, but i couldnt get the dynamic textbox...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.