Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Addition In Vb

I want vb to add 2 values together and produce the result in a seperate txt box when a button is clicked.

Here is the structure:

Text1 + Text2 = Text3. (text boxes)

Button is called 'cmdOK.'

First I want to enter a value in 'Text1,' then another in 'Text2.' Then when I click 'cmdOK' i want the answer to appear in 'Text3.'

If anyone could help me out it would be greatly appreciated.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
XOR Addition Help?

I am new to VB programming? and I need help on XOR addition.

This is what I am planning... suppose I have a string that contains "03000921".

My expected output should be the XOR of all the characters in the string.

But before that each character should be converted first to their equivalent ASCII Hex or decimal then apply an XOR mathematics... the result of the XOR string should be added to the string as the last character... say "03000921x" --> x is the XOR result.

How can I do this in VB6?

I need your help...

Thank u.

This really should not be to hard of a problem to solve. How do I make an Addition Formula? I have 10 text boxes, 5 of tem are being used to add. If you know how to make it add, then please post the simple code here. Thanks

I am trying to add two things together, but when I do it comes up next to each other as such 5 + 15 = 515
Here is my code:

addit = txtCases_U(i).Text
UP = "UPDATE Comm_Amount SET Amount_Remaining = Amount_Remaining + '" & addit & "' WHERE Comm_Amount.Comm_Num = '" & txtCommNumber_U(i).Text & "'"

I always seem to have a problem with basic addition.
But none of my workarounds have worked thus far.

Here is my code:

tot = (tot + value5)

tot is a variable.
value5 is a textbox that contains a single digit integer

When I add them it works like this:
tot = (tot + value5)
12 = ( 1 + 2 )

I've tried appling "Val()" to the textboxes. Didn't work. Tried declaring variables to the textboxes but that didn't work.

Any ideas??

~Complex Solutions to Simple Problems!!~
CornEmpire Ruler

I'm trying to add two number outputs from label boxes:

Label1.Text = Label2.Text + Label3.Text

If the output is:

Label1 = 10
Label2 = 5


instead of:

Label3=15 (which i want)

What am i doing wrong?

how would I go about doing simple addition from predetermined numbers linked to check boxes?

i.e. If check1(0).value = true then + 3.50

if check1(4).value = true then + 1.75

and total when cmdAdd.

the number of check boxes could range from 2 to 30

i have 4 fields. Dataformat of them is Number for all of them.

when i enter numbers in each field and try to add the total, it only give me the value of the last field i used.

Private Sub cmdTotal_Click()
       txtTotal.Text = txtField1.Text + txtField2.Text + txtField3.Text + txtField4.Text
End Sub


i am trying to show the total every time one of the fields changes without clicking on the cmdTotal.

any help,

Textbox Addition?
I have a simple problem, may sound obvious but I've trawled through the forums & nothing works.

I have 8 textboxes and I want to add them up and put the sum into another textbox. I tried out my code on two textboxes, Perm and Casual.

TotalResources_providedbyQR.Text = CInt(Perm.Text) + CInt(Casual.Text)

That gives me an error saying "You can't reference a property or method for a control unless the control has the focus."

I've tried TotalResources_providedbyQR.SetFocus but the same error comes up.

Addition Problem
I have a textbox that gets input of a letter and a number, like P8. I want to add a value in another textbox with the value part of the textbox that has P8. Right now I am doing that with...

MCOtxt.Text = Val(MCOtxt.Text) + Right(Jantxt(j - 1 + cDay).Text, 1)
which works fine, but what if the number is 10, like P10. This code will not work. So I tried...

MCOtxt.Text = Val(MCOtxt.Text) + Val(Jantxt(j - 1 + cDay).Text)
but that didn't work. I thought that this is how you extract a value from text that has a value in it. Is this not how it is done?

Addition In Textbox
I have a text box with the text "344+569" and i want these numbers calculated when the textbox looses focus. I know how to add using two textboxes but i'm a bit confused on how to do it in only one textbox.

Text1.text=val(text1.text) is what i have come up with but that doesn't work.

Date Addition
In VB 6.0 by adding one to today's date you can get tomorrows date.

ie. TomorrowDate = Today + 1
if Today = 11/17/2004 TomorrowDate will return 11/18/2004

How do I do this in

Simple Addition
how can you add a caption to a text box like so?

Label6.Caption = 1 Then Text1.Text = Text1.Text + Label11

it just puts the numbers side by side
this addition works fine:

Label7.Caption = Label7.Caption + 1

Calculator Addition
First off... Hey All

I just been reading about the forum looking for help doing arithmatic functions on a calculator (doing one of those full scientific ones) I checked out the "Adding Strings" one but doesn't really cover my topic.

I'm a complete newbie VB student and part of our project is to make a calculator. I have the following code at the moment for the addition function but it's giving me completely random results, if anyone can help out it would be greatly appreciated :

I declared my variable as public

then for the "+" button:

Private Sub cmdAdd_Click()
If Operator = "+" Then 'if this is second time pressed + button then carry on
Subtotal = Subtotal + lblDisplay.Caption
Operator = "+" ' if its first time, get ready for another value to add it to
Subtotal = lblDisplay.Caption
End If
End Sub

and for the "=" button:

Private Sub cmdEquals_Click()
If Operator = "+" Then cmdAdd_Click

lblDisplay.Caption = Subtotal
End Sub

and an example of my number buttons ("1") :

Private Sub cmdNum1_Click()

If MemoryStatus = True Then
Mem(1) = lblDisplay.Caption
MemoryStatus = False
ElseIf RecallStatus = True Then
lblDisplay.Caption = Mem(1)
RecallStatus = False
ElseIf lblDisplay.Caption = "0" Then
lblDisplay.Caption = ""
lblDisplay.Caption = lblDisplay.Caption + "1"
lblDisplay.Caption = lblDisplay.Caption + "1"
End If
End Sub

Some of the code is related to memory functions and trig functions but any help would be greatly appreciated thanks again

Mathematical Addition
I have 4 textboxes and I want to total them up and place the total number in a separate text box. When I try to add them up the output in the text box is something like 1234 instead of 10.

Latest Addition
Im having a problem with how I should write the calculation portion of this program and in my last post (thinker, if u can remember the code was on there, but u deleted it and i dont remember how i wrote it, i can go think of it again but if u remember it could u tell me what it was) it was written but deleted and i was just needing some input

(btw, the correct one was attached the second time)

thank u for ur help

Time Addition
I may sound stupid in asking this question
How do I add 2 minutes to any given time?

String Addition
I wrote a simple procedure to add strings of numbers one digit at a time. This is slow and taxing on the processor. So I'm trying to write a procedure to add the numbers 13 digits at a time. Here's what I have. I put a whole bunch of comment marks before and after the part that I think is causing the problem. I change tmpSum2 to "" if it's "0", but in actuality I should only do it sometimes and I don't know how to determine when I need to. If I remove the lines in question, Add("9887454823508319666176","92233720368547758080000") returns the correct answer, but then other examples return the wrong answer (which can be fixed by adding the lines). Ideas???

Public Function Add(Num1 As String, Num2 As String) As String

Dim IntegerSum As String, DecimalSum As String, LeftExcess As String, RightExcess As String
Dim Decimal1 As Double, Decimal2 As Double, TopNum As String, BottomNum As String, tmpSum2 As String
Dim CarryThe1 As Boolean, SmallSum As Integer, DecimalPlace As Double, Pieces As Double
Dim IntegerPart1 As String, IntegerPart2 As String, DecimalPart1 As String, DecimalPart2 As String
Dim IntegerPartNotPieces1 As Double, IntegerPartNotPieces2 As Double, DecimalPartNotPieces1 As Double, DecimalPartNotPieces2 As Double

If Num1 = "" Then Num1 = "0"
If Num2 = "" Then Num2 = "0"
If InStr(Num1, ".") < 1 Then Num1 = Num1 & "."
If InStr(Num2, ".") < 1 Then Num2 = Num2 & "."

Decimal1 = Len(Num1) - InStr(Num1, ".")
Decimal2 = Len(Num2) - InStr(Num2, ".")

TopNum = Replace(Num1, ".", "")
BottomNum = Replace(Num2, ".", "")

If Len(Num1) - Decimal1 > Len(Num2) - Decimal2 Then
LeftExcess = Left(Num1, (Len(Num1) - Decimal1) - (Len(Num2) - Decimal2))
Num1 = Right(Num1, Len(Num1) - Len(LeftExcess))
LeftExcess = Left(Num2, (Len(Num2) - Decimal2) - (Len(Num1) - Decimal1))
Num2 = Right(Num2, Len(Num2) - Len(LeftExcess))
End If

If Decimal1 >= Decimal2 Then
RightExcess = Right(Num1, Decimal1 - Decimal2)
Num1 = Left(Num1, Len(Num1) - Len(RightExcess))
RightExcess = Right(Num2, Decimal2 - Decimal1)
Num2 = Left(Num2, Len(Num2) - Len(RightExcess))
End If

IntegerPart1 = Left(Num1, InStr(Num1, ".") - 1)
IntegerPart2 = Left(Num2, InStr(Num2, ".") - 1)

DecimalPart1 = Right(Num1, Len(Num1) - InStr(Num1, "."))
DecimalPart2 = Right(Num2, Len(Num2) - InStr(Num2, "."))

Pieces = Len(IntegerPart1) 13

Dim Len1 As Double, Len2 As Double

IntegerPartNotPieces1 = CDbl("0" & Left(IntegerPart1, Len(IntegerPart1) - (13 * Pieces)))
IntegerPartNotPieces2 = CDbl("0" & Left(IntegerPart2, Len(IntegerPart2) - (13 * Pieces)))
Len1 = Len(IntegerPart1) - Len(CStr(IntegerPartNotPieces1))
If IntegerPartNotPieces1 = 0 Then Len1 = Len1 + 1
Len2 = Len(IntegerPart2) - Len(CStr(IntegerPartNotPieces2))
If IntegerPartNotPieces2 = 0 Then Len2 = Len2 + 1
IntegerPart1 = Right(IntegerPart1, Len1)
IntegerPart2 = Right(IntegerPart2, Len2)

Dim tmpSum As Double, Top As Double, Bottom As Double
For i = Pieces - 1 To 0 Step -1

Top = CDbl(Mid(IntegerPart1, i * 13 + 1, 13))
Bottom = CDbl(Mid(IntegerPart2, i * 13 + 1, 13))
tmpSum = Top + Bottom

If CarryThe1 Then tmpSum = tmpSum + 1

If Len(CStr(tmpSum)) = 14 Then
CarryThe1 = True
tmpSum = tmpSum - 10000000000000#
CarryThe1 = False
End If

IntegerSum = CStr(tmpSum) & IntegerSum


tmpSum = IntegerPartNotPieces1 + IntegerPartNotPieces2
If CarryThe1 Then tmpSum = tmpSum + 1

If Len(CStr(tmpSum)) > Len(CStr(IntegerPartNotPieces1)) Then
tmpSum = tmpSum - 10 ^ Len(CStr(IntegerPartNotPieces1))
CarryThe1 = True
CarryThe1 = False
End If
If tmpSum2 = "0" Then tmpSum2 = ""
tmpSum2 = String(Len(CStr(IntegerPartNotPieces1)) - Len(CStr(tmpSum)), "0") & CStr(tmpSum)
If tmpSum2 = "0" Then
tmpSum2 = ""
End If
If CarryThe1 Then LeftExcess = Add(LeftExcess, "1")
IntegerSum = LeftExcess & CStr(tmpSum2) & IntegerSum

If DecimalPart1 = "" And DecimalPart2 <> "" Then
DecimalPart1 = "0"
DecimalSum = Add(DecimalPart1, DecimalPart2) & RightExcess
ElseIf DecimalPart1 <> "" And DecimalPart2 = "" Then
DecimalPart2 = "0"
DecimalSum = Add(DecimalPart1, DecimalPart2) & RightExcess
ElseIf DecimalPart1 <> "" And DecimalPart2 <> "" Then
DecimalSum = Add(DecimalPart1, DecimalPart2) & RightExcess
DecimalSum = RightExcess
End If

tmpSum = DecimalPartNotPieces1 + DecimalPartNotPieces2
If tmpSum <> 0 Then
DecimalSum = CStr(tmpSum) & DecimalSum
End If
DecimalSum = Replace(RTrim(Replace(DecimalSum, "0", " ")), " ", "0")

If Len(CStr(tmpSum)) > Len(CStr(DecimalPartNotPieces1)) Then
tmpSum = tmpSum - 10 ^ Len(CStr(DecimalPartNotPieces1))
CarryThe1 = True
CarryThe1 = False
End If

If CarryThe1 Then IntegerSum = Add(IntegerSum, "1")

Add = IntegerSum & "." & DecimalSum
If Right(Add, 1) = "." Then Add = Left(Add, Len(Add) - 1)
Add = Replace(LTrim(Replace(Add, "0", " ")), " ", "0")

End Function

Time Addition
i posted a thread on adding two time periods to geather , and i have read on the datadiff function but still can' t figure out how to do what i want to do. i have a database, and on the form it has a textbox with a time (exp. 08:00) and on each record the time is different . i NEED to be able to add the hours and min up
(exp. record1 has a time of 08:00 and record2 has a time of 08:30 = total 16:30 )and i want to be able to press a button and it give me a total of all record times )

Parsing Addition
I am writing an IRC bot and I have it parse for math commands. When I give it 1 + 1, it returns 1 + 1. How do I get it to return instead 2?

Addition Help Needed!
I have a puzzle that I want to set a user. The user is given two blank
text boxes and they have to put two values in that when added
together eqaul the value in a label. The value in the label is 837.
I have made the following code, but it's giving me the 'wrong' msgbox
regardless of which values I put in to the two textboxes.

Private Sub Command1_Click()
Dim intSum1 As String
Dim intsum2 As String
Dim inttotal As String

inttotal = intSum1 + intsum2

intSum1 = txtSum1.Text
intsum2 = txtSum2.Text

If inttotal = Label1.Caption Then
MsgBox "correct"
MsgBox "wrong"
End If

Thanks in advance.

Addition In A Msflexgrid
I have a problem when I try to get a sum of two numbers in different cells in a msflexgrid.

msflexgrid.textmatrix(1,3) = msflexgrid.textmatrix(1,1) + msflexgrid.textmatrix(1,2)

for example
msflexgrid.textmatrix(1,3) = 5 + 4
it gives me
msflexgrid.textmatrix(1,3) = 54
instead of 9

How can I make it work ?


Simple Addition
Ok I seem to be having a problem on the simplest of things

Textbox3.txt = Textbox3.txt + textbox2.txt

Will return 11 in textbox3 which makes sense as is it a string or not but I want a return of 2

I know I should use VAL & declare it but for the life of me I cant figure it out.
Some one please but me out of misery
Ps I have searched

Add green resolved checkmark - Hack

Addition Calc
does anyone have an addition calculator anywhere that they can upload for me? thx
no equals button is prefered but doesnt matt=ter

Addition Calculator
i am trying to create a program that is basically a calculator, but i only want to us it for addition. so i made the number buttons, a "addition button", and a clear button. i made the text box and the label for the final amount to be put into. each time i add a number i want the number on the label to be added to that number, unless i hit clear .. it's like a regular calculator you know? anyway, i set up as much as i could but i don't understnad how to do the actual addition part and the labeling .. here's what i have so far, any help would be really appreciated...

VB Code:
Option Explicit Private Sub cmd0_Click()If txtnumber.Text = "" Thentxtnumber.SetFocus    'keeps keyboard keystrokes activeExit SubElsetxtnumber.Text = txtnumber.Text & "0"   'can't start off with "0"End IfEnd Sub Private Sub cmd1_Click()txtnumber.Text = txtnumber.Text & 1End Sub Private Sub cmd2_Click()txtnumber.Text = txtnumber.Text & 2End Sub Private Sub cmd3_Click()txtnumber.Text = txtnumber.Text & 3End Sub Private Sub cmd4_Click()txtnumber.Text = txtnumber.Text & 4End Sub Private Sub cmd5_Click()txtnumber.Text = txtnumber.Text & 5End Sub Private Sub cmd6_Click()txtnumber.Text = txtnumber.Text & 6End Sub Private Sub cmd7_Click()txtnumber.Text = txtnumber.Text & 7End Sub Private Sub cmd8_Click()txtnumber.Text = txtnumber.Text & 8End Sub Private Sub cmd9_Click()txtnumber.Text = txtnumber.Text & 9End Sub Private Sub cmdClr_Click()txtnumber.Text = ""lblDisplay.Caption = ""End Sub

Addition Program...
I need to write a program to add and and print the answer in the form a/b where a is the numerator and b is the denominator.

Now I have no idea on how to work this out. It is very easy to make it if it result is a fraction value.

Can someone help me out here plz...

Simple Addition
[I posted in wrong forum]

Hey, I'm kind of new kind of not to programing, I know basic syntax's and all that, but for some reason I can't get a simple addition function to work. I'm trying to make a very simple calculator for my first project. It irretates me so much that subtraction, multiplication, division all work but not addition. It does 1+1=11, 25+4=254, etc... Any help? Here's the code:

Private Sub Add_bttn_Click()
Numb_3 = Numb_1 + Numb_2
End Sub
Private Sub Div_Bttn_Click()
Numb_3 = Numb_1 / Numb_2
End Sub
Private Sub Mul_Bttn_Click()
Numb_3 = Numb_1 * Numb_2
End Sub
Private Sub Sub_Bttn_Click()
Numb_3 = Numb_1 - Numb_2
End Sub

Simple Addition In VB
I want to add 2 values together.
I am reading fields back from a database and doing the addition and representing it as a label.


VB Code:
frmSuccess.lblTotal = Read_field("premium") + Read_Field("fee")

In my database Premium = 400 and fee = 50

Unforunately my result gives me 40050 instead of 450!!!

Can anyone point me in the right direction?

IP Address Addition
How do I perform IP address additon if the input is in 1 single textbox?

Suppose if starting IP is and the last one is to be how do i break each octet and perform the addition to reach the last ip.

Addition Problems
I am creating a currency converter that not only converts the currency it also adds the total amount converted together and displays it in US$. My problem is that when I enter an amount to be converted it adds it to my total converted box, but when I add another amount to be converted it replaces the first amount instead of adding them together. How can I fix this? Also, when I close the application I lose all the previous data. How can I save this? I've have heard "SaveSetting" but I don't know how to use it.

Addition Problem
I have to type a single number into the input box then you hit the plus key. This will make that number be added to whatever is in the display box. Then you type a new number in to the input box and hit the plus key again and now this new number will be added to what is in the display and the sum will again be put in the display box. For this one I have to use the case statement and the plus sign must not show up on the form.

Byte Addition

I want to add two byte variables together and if the resulting value is greater than 255, then i want the sum to be set at 255. So far, i have had no luck at all. i tried setting up a temporary int variable like this:

dim x,y,sum as byte
dim temp as integer

temp = x+y

if temp >255 then
sum = 255
sum = temp
end if

but i still get an overflow error. How do i fix this???


Addition Of Binary
Does anyone know how to add binary numbers and if you have any code that would be awesome. for example i need to add binarry numbers like so:

but i know a 1 and 1 cannot be 2 so is a 1 and 1 10 or 01, so as you can see im just making myself confused. Any help would be greatly apprecaited.



Bug Problem- Addition

the error message that I get is "can't find DLL entry point netmessagebuffersend in NETAPI32.DLL"

Thank you.

Adodc Addition
i press the add button which moves to the last record and adds a new lets say i dont want to add a new record doi accomplish that?
it gives an error msg that empty rows cannot be added........?

=B8,=F8=A4=BA=B0`=B0=BA=A4=F8,=B8=B8,=F8=A4=A4 =C5=A7=C4=D0=A4=A4=F8,=B8=B8,=F8=A4=BA=B0`=B0=BA=A 4=F8,=B8

Tel. # 03204016107

Addition Problem
I have a text field linked to an access DB that keeps a running total for me. For certain conditions I am trying to subtract a masked edit field (set to currency on open). When I display a msgbox to verify the total, if I try and perform the following:

txtBalance = txtBalance + mskBox (100 + 25)

I get the display 10025 instead of 125. What am I doing wrong.

Example Of Addition In A Datagrid
Just looking for an example of code that I can extract values from a datagrid and add or subtract those values so they will appear in a textbox. I.E. A datagrid with a column of values. I want to be able to add those values and then convert that info to be place in a textbox on my form. I have tried the column.add etc and other codes but haven't gotten anything to work.

85.00 Total to be place in a textbox 910.00


Stupid Addition
Fried brain on a Friday and I cant solve this...

Private Sub cmdCalculate_Click()

LabelA.Caption = Lblsquad(0) + Lblsquad(1) + Lblsquad(2) + Lblsquad(3) + Lblsquad(4)
LabelB.Caption = Lblsquad(5) + Lblsquad(6) + Lblsquad(7) + Lblsquad(8) + Lblsquad(9)
LabelC.Caption = Lblsquad(10) + Lblsquad(11) + Lblsquad(12) + Lblsquad(13) + Lblsquad(14)
LabelD.Caption = Lblsquad(15) + Lblsquad(16) + Lblsquad(17) + Lblsquad(18) + Lblsquad(19)
LabelE.Caption = Lblsquad(20) + Lblsquad(21) + Lblsquad(22) + Lblsquad(23) + Lblsquad(24)
LabelF.Caption = Lblsquad(25) + Lblsquad(26) + Lblsquad(27) + Lblsquad(28) + Lblsquad(29)

End Sub

I think this will qualify for the most stupidest post lol..

I am a VB learner with huge ideas!! push yourself and you shall learn more

First Project: (Forever GROWING!!)

I aim to assist the Ten Pin Bowling Instructors around the world with this!!!!

Binary Addition
How can I make the following operation in VB??


+ 1

The answer must be:



***NOTE: The binary value is in string format.
Can anyone suggest a piece of coding?

How To Make An Addition To The Registry
hey, how can i add somthign to the registry using vb 6? anyhting you can tell me will help, as i know nothing about this area. thx in advanced

Selective Addition, Help Getting Started
I have a problem. I have an undefined number of products (these are mutual funds) with an undefined number of rows for each product. For each product a report has to be generated. Please view file. The colors simplify things.

Of course, these reports can be generated manually. However, this isn't the most efficient way of doing things.

Can anyone help get me started? What code structures would I use to do something like this? I was thinking I should use some type of loop.

This was done before in VB. Could this be done any easier or just as easily in Excel 2003 with VBA?

Thank you in advanced for any suggestions.

Edit by Moderator:
Please post Excel questions, in the Excel forum.

Thank you.

Making An Addition To My Program
I'm running a little "math" program and it
returns very good results.

I want to add another "lable" and have the
results from the first label divided by 2 and
returned to the new label.

I've tried this many times today with lots of
results......none good.

Here is my code:
Private Sub Command1_Click()
If Text1.Text = "" Then MsgBox "Please Enter A Frequency In The Range 1.8 - 30 MHZ": Exit Sub
Dim sngFeet As Single
Dim sngInches As Single

sngFeet = 468 / CSng(Text1.Text) 'Your "decimal feet"
sngInches = sngFeet - Int(sngFeet) 'Get the decimal part of that

sngInches = Format(sngInches * 12, "0.000") 'Convert it to inches and limit the number of decimals to 3
sngFeet = Int(sngFeet) 'Cutting off the decimal part of the feet

Label2.Caption = sngFeet & " Feet " & sngInches & " Inches" 'displaying result

End Sub

How do I change this to get the results in the
first label, divided by 2 into the second label??

Addition(noob Stuff)
I'm having trouble with a program. The program goes like you select a quantity then it prints total for that. What I'm having trouble is getting a total. It wants to treat them like text. Instead of adding mathematically it prints up like $55.00$65.00. Heres the code for the calculation. Thank you in advance.

Private Sub cmdCalc_Click()
Dim Cur_Amount As String

Cur_Amount = (txtTotCross + txtTotBask + txtTotFit + txtTotRun + txtTotWalk)

txtTot.Text = Format(Cur_Amount, "currency")
End Sub

Addition Sign Doesnt Add
when i try to add the contents of two labels or text box's it just appends it to the end of what's already in there rather than adding the two.


label1= 5
label2 =5

label1 = (label1+label2)

and label1 will come up 55 rather than 10. i imagine it's probably something simple but i've never encountered this before and it's extremely aggravating. thank you for your help.

Whoa Or Woe? Is Me! Addition Problem
I have some labels that contain a number in them. I want to use a function to add the numbers together! It's pretty simple really. Here is my function...

Private Function CalcMisc()
Dim TotalInvoice, Misc, RunningTotal As Variant
Dim Materials, Tax, Labor, Travel, Equipment, LD, Overhead As Variant
Materials = lblmaterialstotal.Caption
Tax = lbltaxtotal.Caption
Labor = lbllabortotal.Caption
Travel = lbltraveltotal.Caption
Equipment = lblequipmenttotal.Caption
LD = lbllampdisposaltotal.Caption
Overhead = lbloverheadtotal.Caption
TotalInvoice = txttotalinvoice.Text
Misc = txtmisc.Text
RunningTotal = Materials + Tax + Labor + Travel + Equipment + LD + Overhead
MsgBox RunningTotal
End Function

Now, I've switched the datatype to a variant cause nothing else worked (data type mismatch). For testing purposes, the labels contained...

4.00 and so on...

When I run the function, it just sticks them all together like they were strings.

I have set the dataformat of the labels at number and general. Nothing works.

How can I get it to perform a simple addition operation on the value of these labels?

Saving Current Addition To Mdb.
I got it to save the first entry to my list view but that is all...
What I am trying to do is, when I click add it will save the new item that was just entered to the listview, and then add it to the next index on the mdb.

Dim dbServers As Database
Dim rs As Recordset
Public db As Database
Public ws As Workspace
Public max As Long

Private Sub Command1_Click()
Set myitem = ListView1.ListItems.Add(, , Text1.Text)
myitem.SubItems(1) = Text2.Text

Set ws = DBEngine.Workspaces(0)
Set db = ws.OpenDatabase(App.Path & "list.mdb")
Set rs = db.OpenRecordset("List", dbOpenTable)

max = rs.RecordCount
rs("Address") = ListView1.SelectedItem.Text

Me.Caption = "You have " & max & " entrys."
End Sub

Private Sub Form_Load()
Me.Caption = "You have " & max & " entrys."
End Sub

can someone help me with this please?

Rounding Error With Addition

I am troubleshooting this code and could not find a solution for this problem.
As you can see it seems that 0.05 is not really 0.05.

What should I do to get multiples of 0.05?

Thank you.


Dim aaa As Double
Dim LOOPER As Integer
aaa = 0
For LOOPER = 0 To 199
aaa = aaa + CDbl(0.05)
Debug.Print aaa & " + 0.05"


0.05 + 0.05
0.1 + 0.05
0.15 + 0.05
0.2 + 0.05
0.25 + 0.05
0.3 + 0.05
0.35 + 0.05
0.4 + 0.05
0.45 + 0.05
0.5 + 0.05
0.55 + 0.05
0.6 + 0.05
0.65 + 0.05
0.7 + 0.05
0.75 + 0.05
0.8 + 0.05
0.85 + 0.05
0.9 + 0.05
0.95 + 0.05
1 + 0.05
1.05 + 0.05
1.1 + 0.05
1.15 + 0.05
1.2 + 0.05
1.25 + 0.05
1.3 + 0.05
1.35 + 0.05
1.4 + 0.05
1.45 + 0.05
1.5 + 0.05
1.55 + 0.05
1.6 + 0.05
1.65 + 0.05
1.7 + 0.05
1.75 + 0.05
1.8 + 0.05
1.85 + 0.05
1.9 + 0.05
1.95 + 0.05
2 + 0.05
2.05 + 0.05
2.1 + 0.05
2.15 + 0.05
2.2 + 0.05
2.25 + 0.05
2.3 + 0.05
2.35 + 0.05
2.4 + 0.05
2.45 + 0.05
2.5 + 0.05
2.55 + 0.05

0.35 + 0.05
0.4 + 0.05
0.45 + 0.05
0.5000001 + 0.05
0.5500001 + 0.05
0.6000001 + 0.05
0.6500001 + 0.05
0.7000001 + 0.05
0.7500001 + 0.05
0.8000001 + 0.05
0.8500001 + 0.05
0.9000002 + 0.05
0.9500002 + 0.05
1 + 0.05
1.05 + 0.05
1.1 + 0.05
1.15 + 0.05
1.2 + 0.05
1.25 + 0.05
1.3 + 0.05
1.35 + 0.05
1.4 + 0.05
1.45 + 0.05
1.5 + 0.05
1.55 + 0.05
1.6 + 0.05
1.649999 + 0.05
1.699999 + 0.05
1.749999 + 0.05
1.799999 + 0.05
1.849999 + 0.05
1.899999 + 0.05
1.949999 + 0.05
1.999999 + 0.05
2.049999 + 0.05
2.099999 + 0.05
2.149999 + 0.05
2.199999 + 0.05
2.249999 + 0.05
2.299999 + 0.05
2.349999 + 0.05
2.399999 + 0.05
2.449999 + 0.05
2.499999 + 0.05
2.549999 + 0.05
2.599999 + 0.05
2.649999 + 0.05
2.699999 + 0.05
2.749999 + 0.05
2.799999 + 0.05
2.849998 + 0.05
2.899998 + 0.05
2.949998 + 0.05
2.999998 + 0.05
3.049998 + 0.05
3.099998 + 0.05
3.149998 + 0.05
3.199998 + 0.05
3.249998 + 0.05
3.299998 + 0.05
3.349998 + 0.05
3.399998 + 0.05
3.449998 + 0.05
3.499998 + 0.05
3.549998 + 0.05
3.599998 + 0.05
3.649998 + 0.05
3.699998 + 0.05
3.749998 + 0.05
3.799998 + 0.05
3.849998 + 0.05
3.899997 + 0.05
3.949997 + 0.05
3.999997 + 0.05
4.049997 + 0.05
4.099998 + 0.05
4.149998 + 0.05
4.199998 + 0.05
4.249998 + 0.05
4.299998 + 0.05
4.349998 + 0.05
4.399999 + 0.05
4.449999 + 0.05
4.499999 + 0.05
4.549999 + 0.05
4.599999 + 0.05
4.65 + 0.05
4.7 + 0.05
4.75 + 0.05

Calculator Addition Not Working
Hey guys, I'm pretty bored and figured I'de make a calculator for my homework and everything. Well I've got subtraction, division, multiplication , etc working, but when I do add it adds the numbers togethor

so, If I add 5 + 4 it equals 54.
If I add 7+2 it equals 72. Everything else works fine. Can anyone tell me what I'm doing wrong?

If addbutton Then
equalbox.Text = onebox.Text + twobox.Text
End If

Simple Addition Problem
First post, so hope this is in the right place.

I'm having trouble making two numbers from two different text boxes add together, with the answer being displayed in a third text box.

Basically if I use the following line of code (with 5 and 5 being the two numbers, for example)

txtresult.text = txtnumber1.text + txtnumber2.text

I will get the result 55, instead of 10.

I've used the same code with a minus instead of a plus, and it has worked fine, so what's the problem?

I have little vb experience, and havn't used it since college (about a year ago), but I have used this line of code before in a calculator and it has worked, I'm sure.

Also, you'll have noticed I haven't declared any variables, and have therefore wrote out the long version of the text boxes name, ie. txtnumber1.text

This is because when I try to do it, I get error messages, again, any ideas?

Thanks in advance for any help

Addition Of Row's Content In Datagrid

In my application i have a datagrid which has a column name Amount. Now i have to calculate the total amount of all the rows and display it in a text box.

how can i add the rows's content in datagrid. Please help me.


Copyright 2005-08, All rights reserved