Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 6th, 2004, 09:56 AM
Authorized User
Join Date: Jan 2004
Location: Blair, , United Kingdom.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding Values

Hi Im trying to add values in VB, the program calculates 4 different values within separate text boxes, there is then a final "total" text box, however when I try to add these to get a total, it just lists the 4 totals one after the other. Just cannot get it to calculate a total!
Help Please!

Old February 6th, 2004, 10:45 AM
Authorized User
Join Date: Feb 2004
Location: Leeds, West Yorkshire, United Kingdom.
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts


It sounds like you're just adding the string values in the text fields together, you'll need to create a function in a module ( or wherever) to turn these into integer / double values and then return the answer.
This code worked for me

Private Sub Command2_Click()
Dim int1 As Integer
Dim int2 As Integer
Dim int3 As Integer

int1 = Text1.Text
int2 = Text2.Text
int3 = Text3.Text

Label1.Caption = int1 + int2 + int3

you'll need to do some validation in the text boxes but that's easy enough!


Don't think, do!

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding up values in xslt northwind XSLT 21 February 17th, 2017 09:07 AM
adding values between datasets Ashubhatt BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 June 19th, 2008 04:37 AM
Adding the values within an array Dave_Richards Beginning PHP 0 November 8th, 2006 04:34 PM
Adding 2 values in a table Regornil JSP Basics 2 September 13th, 2004 02:32 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.