473,387 Members | 1,561 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,387 software developers and data experts.

the sum of two combo boxes in another text box

I have two combo boxes, freight and Rigging both have drop down selections from a table. I have a third text box i want the sum of these two boxes in. I can't seem to get it to add right.
Feb 22 '17 #1
2 1150
PhilOfWalton
1,430 Expert 1GB
In which columns are the prices held?

Phil
Feb 23 '17 #2
Not a lot of data to go on so I will assume what you are trying to do is something along the lines of obtaining a total cost.

I would handle it something like this:

Expand|Select|Wrap|Line Numbers
  1. txtTotalCost.Value = CDbl(Freight.Value) + CDbl(Rigging.Value)
  2.  
Without using CDbl(), if the values in freight and/or rigging are strings the result will be a concatenation of the two values which isn't what you would want based on my initial assumption.

(e.g. "10000" + "100" = "10000100")

CDbl() converts whatever datatype the value is in the box to a numeric value (provided the value is identifiably numeric and not something like "RED" which will throw an error) so the result is an addition of the values rather than a combining.

(e.g. CDbl("10000") + CDbl("100") = 10100)

To get the textbox to have an initial value as you load the form and move through the records, put the code in the Form's On Current event. To update the value if the numbers change in the comboboxes put the same code in the After Update event of the comboboxes.

Or... better yet, create a function to do it and just call the function from the Current and After Update events. That way you aren't redundantly repeating code, and if you ever have to update the formula you can update it in just one place and not have to find every instance of it.
Mar 2 '17 #3

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

Similar topics

1
by: Daniel Hill | last post by:
OK, I have very, VERY basic background knowledge of VB6 and have now upgraded to VB.NET and now I'm struggling to bring up the forms I want. What I am looking to do is to have a click a command...
0
by: Jim | last post by:
Hi, there, I am a beginner on Access. I have been taking so long time to try to figure out his, but so far, no clues. I want to select 2 combo boxes and Access will automatically fill in...
1
by: Brendan | last post by:
I am trying to validate the data in all of the text and combo boxes. The text box validation seems to be working fine, but I am having the hardest time with the combo box validation. I am not sure...
0
by: Tom | last post by:
I have some very strange issues with combo boxes on a tab control. Here's the scenario: I have a Windows Forms form that has a tab control on it, with two (2) tabs. Tab 2 happens to have a number...
6
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
2
by: Dave | last post by:
I have 3 tables of information feeding into 4 combo boxes on my main form (DR Form). I have as many list boxes (acting as text boxes) as there are fields in each one of the 3 tables. Once...
10
by: BeaBea | last post by:
Hi All, I have been reading some of the threads in your forum and decided to join and post my question. Hopefully it won't be too lengthy. I have created an Unbound Form called paramform2. ...
0
by: Lionhear | last post by:
I have XML file with name "mobiles.xml"; The XML file looks like; <mobiles> <brand name="Nokia"> <model>Lumia 720</model> <price>Rs. 27,600</price> <model>Lumia 510</model> <price>Rs....
4
by: Denielle | last post by:
Currently I have a form that has bound text boxes and combo boxes on it. Some of the combo boxes are pulling the information from other tables and some are manually entered in. I would like to...
1
by: Bhawesh9975 | last post by:
Hellow, I am trying to make Railway time table in excel through Visual basic. I have 2 combo Boxes (From and To)& Multiple Text Boxes to populate Train No, Train Name, Arrival & departure (TextBox...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.