multiplication

G

Guest

i have a userform for a carpet company which has a combo box with a list of
available carpets. once the user selects from the list the price of that
certain carpet per sqaure metre is shown in a text box below (each carpet has
a different price per square metre) that all works fine!!!

BUT.... the user has to type in the number of sqaure metres they need (which
is fine as they type it manually), but i then need a formula to multiply
these together to get a total cost (baring in mind the prices of the carpets
are all different and the number of sqaure metres they type in will be
different each time!!!)

e.g. i need the number of sqaure metres multiplied by the price per sqaure
metre!!!

hope i have explained myself properly!
thanks
 
H

Harald Staff

Something like

Dim Tot as Double
Tot = Val(Textbox1.Text) * Val(Textbox2.Text)
Textbox3.Text = Format$(Tot, "# ##0.00")

HTH. Best wishes Harald
 
G

Guest

Using the change event for each text box, add code that multiplies the value
of the two text boxes and populates a lable with the resulting amount. The
code will look something like this (you will have to validate that both text
boxes contian numbers before running this code)...

Label1 = format(value(textbox1.text) * value(textbox2.text), "#,##0.00")
 
G

Guest

Sorry... Where I have Value, use Val (similar to Harald's code...). I would
be more inclined to use a leble than a Text Box (as Harald uses) as text
boxes are designed for the user to enter text into where as lables are
designed to display text with no ability for the user to change the value...
 
H

Harald Staff

Jim Thomlinson said:
I would
be more inclined to use a leble than a Text Box (as Harald uses) as text
boxes are designed for the user to enter text into where as lables are
designed to display text with no ability for the user to change the
value...

Hi Jim

Sometimes users should be allowed to Ctrl-C the result, which would be a
reason to use a textbox. Otherwise labels make more sense, absolutely.

Best wishes Harald
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top