Loading

how to capture a function

1 post / 0 new
Offline
Joined: 01/23/2010
how to capture a function

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.

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.