Link to home
Start Free TrialLog in
Avatar of skathari
skathari

asked on

Function procedure

On this one , I want to do 2 things
1) write a function procedure that receives the value stored in an integer variable named intNumber. The procedure, named DivideNumber, should divide the integer by 2, and then return the result (which may contain a decimal place)
2)write an appropriate statement to call the Dividenumber function created above.

Any help would be greatly appreciated... thx.
Avatar of dsabo
dsabo
Flag of Venezuela, Bolivarian Republic of image

Here you have one solution:

Private Function DivideNumber(ByVal Number As Integer) As Double
     Dim result As Double
     
     result = (Number / 2)

     Return result
End Function

to call the functio you must do the following:

Dim number As Double
Dim intNumber As Integer

intNumber = 2
number = DivideNumber(intNumber)

That's it.
This sounds like homework and experts answering those questions can get suspended..  you better give it a try at least, as it wont be too difficult for you.... have some problem ask us...
Avatar of skathari
skathari

ASKER

its not homework.... these are just practice for us. What I am trying to get, is an example simple just like this, and then try to remember it and see how they do it.
In other words, its optional for me to practice... practice gets you better.
Avatar of Howard Cantrell
FYI .....
Hi,

Here is where I found good examples for working in VB.Net

.....http://msdn.microsoft.com/vbasic/downloads/samples/101samples.aspx

Link for ASP programs...

http://msdn.microsoft.com/asp.net/downloads/kits/default.aspx 

in VB.NET this can be wriiten as:

Private Function DivideNumber(ByVal Number As Integer) As Double
     
     return Number / 2

End Function


AW
ASKER CERTIFIED SOLUTION
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops, minor type:

should read:

MessageBox.Show("DivideNumber(" & intTest & ") = " & dblAnswer)
but, dont we have to add a button?
Hi skathari,

You didn't ask for a GUI on top of the function.  You simply asked for a function to do X.  The button code is not part of the function.

At any rate, it sounds like you need to see some complete working code...

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you guys... it is working perfect!!!