Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics 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 December 10th, 2005, 01:12 PM
Authorized User
 
Join Date: Dec 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default How Do I Sum Numbers In a TextBox

Boy, I seem to be having trouble with the simple things now! In most of my Access applications I do a lot of summing of numbers entered in Text Boxes and the results are stored in other Text Boxes.

Have tried several schemes but continue to get:

Operator '+' is not defined for types 'System.Windows.Forms.TextBox'

Does this mean there is no way to do calculations using data entered into text boxes?

How about a short example of how to get input from two text boxes and sum them to a third text box that is tied to a table.

Thanks,

George

 
Old December 10th, 2005, 01:29 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

George, first of all you get the value in the textbox with this syntex

Code:
 textBox1.Text
if textBox1 is the name of your textbox control.


Secondly, if you would write somthing like

Code:
 textBox1.Text + textBox2.Text
you will not get the sum but the concatination of the two values stored
in the two text boxes, cause everthing in text boxes is treated as a string
in VB .NET. You will acutally have to do something like

Code:
 Convert.ToInt32(textBox1.Text) + Convert.ToInt32(textBox1.Text)
to get the sum.

Simple thing it is, no doubt, but it'll take u some time to get accustumed VB .NET's ways.
But you will be doing fine, I'm sure, 'cause VB .NET is a very friendly language otherwise.

Regards
Ankur Verma





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum Textbox Values Snuffles ASP.NET 2.0 Basics 1 April 13th, 2007 01:36 PM
Help: Running Sum (or Cumulative Sum) timdasa VB Databases Basics 1 August 22nd, 2006 03:12 PM
textbox names wth numbers popweasel VB How-To 1 January 3rd, 2006 06:50 PM
Sum of random numbers in a table with XSLT Tschuri XSLT 0 May 8th, 2005 04:14 AM
Sum of All Integers Between 2 numbers bicho Classic ASP Basics 4 July 6th, 2003 01:01 PM





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