How do I use VBS in a form?

J

jelwp

I know virtually nothing about VBS. I am making a form for contracts, and I
want numbers with decimals to round up. But where and how do I insert the
VBS code to get the numbers in a field to round up?
 
J

Jean-Guy Marcil

jelwp was telling us:
jelwp nous racontait que :
I know virtually nothing about VBS. I am making a form for
contracts, and I want numbers with decimals to round up. But where
and how do I insert the VBS code to get the numbers in a field to
round up?

You may not need code for this.
Explain the type of form/fields you are using and we will explain how to
format them without decimals.


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

jelwp

It's a contract and I want fields to calculate discounted rates. It
essentially goes like this:

"If you pay on time there is a 3% discount of f(Totalprice*.03). That
brings your final payment to f(FinalPayment-(Totalprice*.03)). The
discounted total will be
f(Totalprice-(Totalprice*.03))."

Now I want to be sure that the discount and the final payment/dicounted
total add up. If anyone can suggest a more efficient way to do this, I would
really appreciate your advice!

JELWP
 
J

Jean-Guy Marcil

jelwp was telling us:
jelwp nous racontait que :
It's a contract and I want fields to calculate discounted rates. It
essentially goes like this:

"If you pay on time there is a 3% discount of f(Totalprice*.03). That
brings your final payment to f(FinalPayment-(Totalprice*.03)). The
discounted total will be
f(Totalprice-(Totalprice*.03))."

Now I want to be sure that the discount and the final
payment/dicounted total add up. If anyone can suggest a more
efficient way to do this, I would really appreciate your advice!

We still need to know if you are talking about a protected form or a
userform.
Where do Totalpriceand FinalPayment come from?
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

jelwp

Oh, right. This is a template for creating a customer contract for our home
improvment business. Having these formulas automates the calculations within
the contract based on the specifics of the job. I'm not sure if that makes
this a protected form or a userform.

"TotalPrice" is a value entered by the contract-writer. After TotalPrice is
entered, the user enters "FirstPayment" and any subsequential payments, and
then "Final Payment" is calculated.

We offer a 3% discount for speedy payments, and the contract states the
discount. I am trying to make sure that the 3% discount and the Discounted
Price reflect one another properly - that the discount rounds up and the
price rounds down, or vice versa.

Thanks for your help.
 
J

Jean-Guy Marcil

jelwp was telling us:
jelwp nous racontait que :
Oh, right. This is a template for creating a customer contract for
our home improvment business. Having these formulas automates the
calculations within the contract based on the specifics of the job.
I'm not sure if that makes this a protected form or a userform.

"TotalPrice" is a value entered by the contract-writer. After
TotalPrice is entered, the user enters "FirstPayment" and any
subsequential payments, and then "Final Payment" is calculated.

We offer a 3% discount for speedy payments, and the contract states
the discount. I am trying to make sure that the 3% discount and the
Discounted Price reflect one another properly - that the discount
rounds up and the price rounds down, or vice versa.

So, it seems you are building a protected form.
You are inserting fields from the Form toolbar and TotalPrice is the name of
the bookmark from the field dialog, right?

Now, when you wrote:
"I want numbers with decimals to round up"
did you mean that you want to let the user enter decimals, but round up
these entered numbers after the user moves on to another field?
Or, let the user enter decimals, but in the calculated fields, round up the
results?
Or not let the user enter decimals (i,e. ignore any entered decimals)?


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

jelwp

The user can't enter decimals, only whole numbers. But by nature of the
math, when calculating 3%, there is usually a decimal involved. I keep all
the numbers as whole numbers, and I want to be sure that the math adds up
properly when the decimals are dropped.

JEG
 
J

Jean-Guy Marcil

jelwp was telling us:
jelwp nous racontait que :
The user can't enter decimals, only whole numbers. But by nature of
the math, when calculating 3%, there is usually a decimal involved.
I keep all the numbers as whole numbers, and I want to be sure that
the math adds up properly when the decimals are dropped.

The easiest is to add your formfields, then, to access their properties,
double click on the ones the user will use to enter numerical data. Select
"Number" as type and in the Format drop down, choose the currency one, once
it is selected, go in the field and remove the decimal separator and the
decimals. If you have a lot of formfields to format that way, just copy the
first format you customize and then paste it in the other formfields. Also,
while in the property dialog, give your formfields descriptive name in the
Bookmark field, names other than "Text1", "Text2", etc.

For the results fields, use "Calculation" as type, use the same format, and
in the Expression field, enter something like: =Textfield1*0.03 (Where
"Textfield1" is the bookmark name of a formfield).

Finally, at least one of the user-entered number fields should have the
"Calculate on exit" box check so that the Calculation fields update
automatically as the user navigates through the form.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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