how to capture a function

Submitted by jomblix on
dear all, i am a newbie in programming i want to make a function in module (bas module and the name in property is functions). in there i write code like this : function math(x as int) as int p = 0 For i = 1 To x p = p + 2 Next i end function when a make a form and i put two textboxes (text1 & text2 ) and a commandbutton. in there, i want to capture the result of function math by writing in command_click() by coding like this private sub command1_click() number= int(text1.text) result = functions.math(number) text2.text = result end sub after i run the program and i fill text1.text with 2 and i click command1.button, the result of text2.text is 0. the correct answer should be 4. i didn't know yet how to capture the result of the function. do any one could help me and correct my code ? thanx for your help.