I am trying to write a function called BATAVE, using (Hits/Bats)*100. I can make into a procedure but I need it in a function. I tried everywhere to see how but no luck so if anyone can help me thanks.How do I write a fuction for this problem in VB?
pretty much the same as a Procedure. Been awhile since I've done VB but the general idea would be
function BATAVE(hits, bats)
BATAVE= (hits/bats)*100
end function
then in your vb code just call by doing something like
textbox.text = ';Your Average is: '; %26amp; BATAVE(30, 50)
How do I write a fuction for this problem in VB?
Same, you just need a return value for the function.
yes, just return.
instead of procedure BATAVE....
use
function BATAVE...
return (Hits/Bats)*100
end function
private function BATAVE(pHits as integer,pBats as integer) as integer
return pHits/pBats * 100
end function
then to test
messagebox.show(BATAVE(10,2))
No comments:
Post a Comment