Re: Rounding Up function ??
RoundUp
There is a function which truncate all decimalparts (Int(Yournumber), if you add just 1 to the result you are done.
Variable-Scope
Declare all variables in the module and then your done.
Re: Rounding Up function ??
Re: Rounding Up function ??
@ceiling fn is used in excel not in vba i want something similar to it......int(value)+1 is one way of rounding up a value...but i want to know where there is a direct fn or not.....
and for my second question
if i declare the variables in 1 module can other models access these variables and the values in one module are to accessed by other modules and forms.....
will u please take some more time to correct the above given example of mine to my requirement..
Re: Rounding Up function ??
No there is not a premade function in vba. Only round and fix function.
I cannot fix any example because i do not do vba since access 2000 and i have no office at hand.
Re: Rounding Up function ??
it needn't be a VBA code...try a vb program for it...i'll change it accordingly....
Re: Rounding Up function ??
you can use excel ceiling function in excel vba
vb Code:
rndup = worksheetfunction.ceiling(1.1, 1)
Quote:
if i declare the variables in 1 module can other models access these variables
yes if declared public
Re: Rounding Up function ??
@westconn
did u read my first post ( above)
can u make a code as per my requirement ????
Re: Rounding Up function ??
Quote:
can u make a code as per my requirement ????
what is your requirement, that is not covered by suggestions above?
in excel VBA, you can use either ceiling or roundup worksheetfunctions, or the int function as suggested by opus
Re: Rounding Up function ??
Quote:
Originally Posted by
dmanojkmr
Secondly I want to create different modules of a program that i have coded into a command button click.
my purpose is that, the module1 i have created should access the variables declared under the userforum---->cmd_clk
and also the value i got from the module1 should be accessible to the userforum-->cmd_clk
Eg.
under userform---> cmd_clk
dim a as integer
dim b as integer
dim c as integer
a=a1.text ' a1 is the text box used in userform
call m1
c=a+b 'the value of b should be got from module1
Msgbox(c)
end sub
under ---> Module1
**** m1()
b=2*a 'b should access the declaration what i made in the cmd_clk
msgbox(b)
end sub
I hope you understand my question.It may be silly for u guys...but i'm new to these coding and stuffs...please just tolerate this..
waiting for your reply.
I want u to make the above codes as per my requirement....
Re: Rounding Up function ??
Quote:
b=2*a 'b should access the declaration what i made in the cmd_clk
best way is to pass a to function, rather than using global variables,
Quote:
c=a+b 'the value of b should be got from module1
b should be the return value from a function
vb Code:
'under userform---> cmd_clk
dim a as integer
dim b as integer
dim c as integer
a=a1.text ' a1 is the text box used in userform
b = m1(a)
c=a+b 'the value of b should be got from module1
Msgbox(c)
end sub
vb Code:
public funtion m1(a as integer)as integer
b=2*a 'b should access the declaration what i made in the cmd_clk
msgbox(b)
m1 = b
end sub
Re: Rounding Up function ??
Can't you just use the built in rounding function and pass it the number to be rounded + .499999999 ?
Like: MyNumber = Round(TheNumber + 0.4999999)
Which means if TheNumber is 3.1 or even 3.9 then MyNumber will be 4.0 in either case
Re: Rounding Up function ??
wow...gr8 thankyou west conn and all other who supported it.....I'l b grateful
I'll try the above code and reply you...
thankyou again..
Re: Rounding Up function ??
Hey...guys i got a another problem.....
actually i thought of using the int()+1 function. but if i want to have the value of 2.1 as 3 but this int+1 fn. makes even 2.0 as 3 which is not desirable .....
also i can't use the worksheet fn. as i'm in another software called MicroStation a drafting software for mechanical engineers....
but though i used an if else statement to solve this prob...but it would be nice to have a handy function like Roundup as in excel.