473,626 Members | 3,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to add Multiple textbox values as they are updated?

110 New Member
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 6342
Fuzz13
110 New Member
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 Recognized Expert Top Contributor
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 New Member
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
4969
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
1988
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 Machine_Count(MachName, CoinsIn) values(txtMachineName(1).Text, txtCoinsIn(1).Text)
4
2558
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 multiple records and want two values depending on the row they select. slaveform: x=selected
7
2215
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 tabel. I know the SP works, because a smalldatetime-field in the database is changed. I've tried to disable viewstate on all textbox controls. Any ideas to solve this problem.
4
8754
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 textboxes pre-fill with data (reason for using datalist) which will capture user input and changes to the textboxes. So the 6 textboxes in columns will be constant but the rows will vary representing each part. I am looking to loop through...
8
5198
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 more than one value, for example three int-s, I would have to change my "logic" and pass the references to my
1
9352
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 need to open the new page in the main page window with passing the two textbox parameters into the new page. Program opens the new page but dont know how to pass the two textboxes values into the new page name deceasedToday.asp Needs help in...
0
1672
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 content(string) is not taken.if i am using enctype= text/plain,then the textbox valus is coming(valus can displayed in the internet explorer.....but the uploading is not coming...what to do... here any code for write the textbox values into a file...
1
1619
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 = (TextBox)EditEventForm.Rows.Cells.Controls; TextBox EndTime = (TextBox)EditEventForm.Rows.Cells.Controls;
9
4013
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 values, Pllssssssssss help how can i get the dynamic values using vb.net pls help me as soon as possible regards kumar thanxxx....
0
8266
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8638
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.