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.
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.
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...
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.
In other words, its optional for me to practice... practice gets you better.
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
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
Private Function DivideNumber(ByVal Number As Integer) As Double
return Number / 2
End Function
AW
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oops, minor type:
should read:
MessageBox.Show("DivideNum ber(" & intTest & ") = " & dblAnswer)
should read:
MessageBox.Show("DivideNum
ASKER
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...
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you guys... it is working perfect!!!
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.