Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

How do I use VBS in a form?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jelwp - 13 Sep 2005 15:45 GMT
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?
Jean-Guy Marcil - 13 Sep 2005 18:30 GMT
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.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

jelwp - 13 Sep 2005 22:28 GMT
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

> jelwp was telling us:
> jelwp nous racontait que :
[quoted text clipped - 7 lines]
> Explain the type of form/fields you are using and we will explain how to
> format them without decimals.
Jean-Guy Marcil - 14 Sep 2005 03:55 GMT
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:
[quoted text clipped - 7 lines]
> 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?
Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

jelwp - 14 Sep 2005 12:01 GMT
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.

> jelwp was telling us:
> jelwp nous racontait que :
[quoted text clipped - 14 lines]
> userform.
> Where do Totalpriceand FinalPayment come from?
Jean-Guy Marcil - 14 Sep 2005 19:35 GMT
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
[quoted text clipped - 9 lines]
> 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)?

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

jelwp - 15 Sep 2005 11:48 GMT
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

> jelwp was telling us:
> jelwp nous racontait que :
[quoted text clipped - 24 lines]
> results?
> Or not let the user enter decimals (i,e. ignore any entered decimals)?
Jean-Guy Marcil - 15 Sep 2005 14:07 GMT
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.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.