Function to do calc on user input field

marathonlady

Registered User.
Local time
Today, 16:39
Joined
Jul 10, 2002
Messages
120
I have a hard time with functions. Can anyone write one that:

The user enters a number into Text1. The function needs to
calculate a tax that is: Round(Text1/500)*4.3

The number needs to be rounded up.

Do I call the function from the AfterUpdate event on Text1?

thanks in advance for your help.
 
why not add one?

i don't know if this might help but if you need to just display a number that is rounded up, why not just add one (1) to the result before using the 'Round' function... this way, it'll round down but it would look like it rounded up

It might look something like this....

Round(Text1/500+1)*4.3
 
Last edited:
While not a precise response to your problem, the following might inspire some ideas. Copy / past to a module then, from the debug window, type ? xyz
Code:
Function XYZ()
Dim curIn, curOut1, curOut2, fmt, Msg, NL, TB, amtHold

fmt = "###,###,##0.00"  ' Define money format.
NL = Chr(13) & Chr(10)  ' Define newline.
TB = Chr(9) ' Define tab.

Msg = "Enter the amount to be processed."
curIn = InputBox(Msg)
curOut1 = "$ " & Format(4.3 * (curIn / 500), fmt)
curOut2 = "$ " & Format(CInt(4.3 * (curIn / 500)), fmt)

Msg = "Amount input:" & TB & TB & "$ " & curIn & NL & NL
Msg = Msg & "Processed amount is: " & TB & curOut1 & NL & NL
Msg = Msg & "Which rounds to: " & TB & curOut2
XYZ = MsgBox(Msg, vbInformation, "In response to your enquiry")

End Function
 
It doesn't round up

i don't know... i might be wrong but I tried using your method... however the amount rounds DOWN to the nearest dollar. I think the number needs to be rounded UP. :cool:
 
The previous example rounds 'properly'. To always round up to the next highest integer, replace curOut2 = line with:

curOut2 = "$ " & Format(Int(curOut1 + 0.99), fmt)
 

Users who are viewing this thread

Back
Top Bottom