Can someone help me with this!

DaniBoy

Registered User.
Local time
Today, 08:31
Joined
Nov 18, 2001
Messages
174
Hello,
Can you tell me if this code is written right? if not whats wrong with it.

#1
Function Addition(ByVal MyVar as Integer)
MtVar = MyVar + 1
Addition = MyVar
End Function

Sub command_OnClick()
Dim MyVar as Integer
Dim result as Integer
MyVar = 99
Result = Addition(MyVar)
MsgBox(result)
MsgBox(MyVar)
End Sub
After the button name “command” is clicked what is displayed?

#2

Consider the following:
Sub ShowValue()
Dim X as Integer
X=3.6
Msgbox(X)
End Sub

What should you get on the msgbox?


Thanks
 
I have not tried direct display of numerics in this context, but I would have thought you needed something like CStr(MyVar) in order to be able to display it in a message box as in your #1. Ditto #2 case.

If you used MSGBOX(CStr(MyVal)) after the click, you might see 99. And MSGBOX(Cstr(Result)) should be 100.

As to the other one, I think MSGBOX(CSTR(X)) would give you either 3 or 4.
 

Users who are viewing this thread

Back
Top Bottom