473,402 Members | 2,053 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,402 software developers and data experts.

Add (rather than concatenate) numbers from two text boxes

Hi. Juts started to try vb and have been getting along fine until I tried to create a simple addition. I have to text boxes which a user enters to scores in. All I want is the third box to produce the addition. But everytime I try it just puts the two together. So for example if the two numbers were 23 and 24 it would produce 2324. I relise this is probably extremely simple, lol, but please help me.
Jul 18 '07 #1
4 4319
the following code theory could be applied to most concepts. however a couple notes, i used integer because of memory allocation and speed, so if your numbers are going to be integers obviously this is the best choice but if your going to have decimals or radicals then use double.

Expand|Select|Wrap|Line Numbers
  1. dim x as integer
  2. dim y as integer
  3. dim z as integer
  4. x = textbox1.text
  5. y = textbox2.text
  6. z = x + y
  7. textbox3.text = z
  8.  
Hi. Juts started to try vb and have been getting along fine until I tried to create a simple addition. I have to text boxes which a user enters to scores in. All I want is the third box to produce the addition. But everytime I try it just puts the two together. So for example if the two numbers were 23 and 24 it would produce 2324. I relise this is probably extremely simple, lol, but please help me.
Jul 18 '07 #2
Worked perfectly, thank you very much =)
Jul 18 '07 #3
Killer42
8,435 Expert 8TB
...i used integer because of memory allocation and speed, so if your numbers are going to be integers obviously this is the best choice but if your going to have decimals or radicals then use double.
Actually, that depends on whether you are using VB6 or Vb.Net (any VB version later than VB6).

In VB6, unless you are extremely short on memory and dealing with very large arrays, the Long data type is almost always preferable to Integer. That's because being the "native" data type on the 32 bit processor, it is actually very slightly faster to process, as less conversion steps are required. (On an old 8 or 16 bit processor, or a 64 bit processor, of focurse, things will be different.)

If you are using VB.Net then I believe they have renamed the data types, so possibly Integer will again be the better way to go.
Jul 19 '07 #4
Hmm thanks killer, i wasnt aware that they changed things around like that ... damn M$ stop screwing with things :-)
Jul 19 '07 #5

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

Similar topics

0
by: mkarja | last post by:
Hi, I have a GUI which has textboxes in it. Those boxes can contain either numbers or text. The problem is that the numbers allways goes to the other side of the box than text. They should both...
30
by: priya | last post by:
Hi How to concatenate two integer Values. Example Program : #include "Port.h" #include "BinaryConversion.h" # include "iostream.h"
2
by: Paulo Rodrigues | last post by:
Hi I would like some help about the following : I have a text field and I don't want it contains any numbers. How can I limit this situation ? So far, I couldn't find literature exacly...
8
by: Sharknwfk | last post by:
Hi, Hoping someone can help. I am trying to concatenate the ages of still living children divided into male & female. So, male 23, female 25, male 13, female 18 should look like this. ...
0
by: Sharknwfk | last post by:
"Sharknwfk" <sharknwfk@co.nz.uk> wrote in message news:41bc8f61@clear.net.nz... > > "Chuck Grimsby" <c.grimsby@worldnet.att.net.invalid> wrote in message >...
7
by: Shannan Casteel via AccessMonster.com | last post by:
I have a form for entering part numbers along with the associated quantity for each part. There are 25 Part fields and 25 associated Quantity fields. If I go to record 1 and enter part number 1234...
3
by: Tom | last post by:
Hi I want to retrieve database data and concatenate them to a string. Here is my code .ToString()); //runtime error her } while (dr.NextResult()) string array =...
6
by: TSGB | last post by:
Hi, I have a Table which has 2 Double, Fixed Number fields to 3 decimal places. This fields are populated as the result of 2 division operations which lead to multiple decimals (the numbers...
10
by: Aaron Hoffman | last post by:
Hello, I'm hoping someone might be able to offer some guidance to my problem. I have one query in MS Access which consists of 2 tables joined by a SEQUENCE_ID. By joining the two tables I am...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...
0
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...
0
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,...

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.