-
Calculation Problem
Need help in calculating Quantity with Rate. I have Labels as:- Quantity, Rate, Amount, Total of Quantity and Total of Amount.
Text Box as Quantity Rate And Amount in 4 rows
What code I should write to get output in Amount, Total of Quantity and Total Amount
Vivek (viv345)
Edit by admin: no contact info permitted on the forum, thank you
-
Re: Calculation Problem
Hello ...
Very precise explanation and precisions !
how many labels have you got ?
are they belonging to an indexed array group ?
What is Rate, exactly ?
I am afraid no one could answer without a very efficient crystal bowl !
Be very precise, please ... Il you are not able to do it with simple words, try with an example of your requirements :
- I have this (describe/show)
- and the result would be (describe/show).
-
Re: Calculation Problem
I have got:-
Labels Quantity Rate Amount
Text [ ] [ ] [ ]
Text [ ] [ ] [ ]
Text [ ] [ ] [ ]
Label
Total of Quantity [ ] Total of Amount [ ]
-
1 Attachment(s)
Re: Calculation Problem
I have attached the screen shot for consideration
-
Re: Calculation Problem
Code:
Text3.Text = CStr(Val(Text1.Text) * Val(Text2.Text))
'...8 = 7 * 6
'...11 = 10 * 9
Text4.Text = CStr(Val(Text1.Text) + Val(Text6.Text) + Val(Text9.Text))
'...5 = 3 + 8 + 11
Good Luck
-
Re: Calculation Problem
-
1 Attachment(s)
Re: Calculation Problem
Sir, after giving the code given by you it is not calculating the Amount. Pl. check what wrong I have done.
-
Re: Calculation Problem
Well it seems that you have more than one Text3 control... Do you know how I know this??? (Index As Integer)...
So, first make sure that you only have one text box control named Text3 and make sure its index property is a blank (has no value on property page). Then remove Index As Integer from your sub...
Good Luck
-
Re: Calculation Problem
Also, don't calculate Text3 when it changes. You want to calculate only when Text1 or Text2 changes!
-
Re: Calculation Problem
Good catch dglienna, I totally missed that :) ...
-
Re: Calculation Problem
Sorry Sir not got your point. Can you please in detail.
[Private Sub Text3_Change(Index As Integer)
Text3.Text = CStr(Val(Text1.Text) * Val(Text2.Text))
End Sub]
Should i remove Private SubText3_****(Index as Integer)
Plz.
-
Re: Calculation Problem
-
Re: Calculation Problem
No, please reread post slowly and carefully and follow D's advice...
-
Re: Calculation Problem
Please check the names of yll your textboxes and you will find mor than one textbox with the name of Text3. It seems that you might have created a TextBox array, possibly by incident without wanting that.
It becomes obvious because the change event of box Text3 gets the Index Parameter.
A normal TextBox event does not get a parameter supplied.
What you are supposed to do:
When you have located the Text3 boxes, give one of them a new name.
Then in bith of them remove the Index property. Simply delete the number in the property list.
Index property must be blank.
Then you reconsider Davids hint, that you dont want to change Text3 while it is already changing. This will create an endless loop.
The statement: Text3.Text = CStr(Val(Text1.Text) * Val(Text2.Text))
has to go to the Change() events of Text1 and Text2, not to Text3_Change() at all
-
Re: Calculation Problem
In this way:
[Private Sub Text_Change()
Text3.Text = CStr(Val(Text1.Text) * Val(Text2.Text))
End Sub]
OR
[Private Sub Text1_Change(Text2.Text)
Text3.Text = CStr(Val(Text1.Text) * Val(Text2.Text))
End Sub]