• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA_Variable Problem

KishorKK

Member
Hi All,

Can someone help me with this,

Sub test()
InputBox ("Enter your name")
x = InputBox("Enter first number")
y = InputBox("Enter second number")
MsgBox (x)
MsgBox (y)
MsgBox (x + y)


End Sub

upload_2016-10-31_17-28-46.png

i'm getting this error!!



POST MOVED BY MODERATOR.

.
 
Last edited by a moderator:
On the top of your code module..do you have
Code:
 OPTION EXPLICIT
written??

If yes, then you have to declare all your varaibles before you start using them in your code..

The solution would be, either remove
Code:
 OPTION EXPLICIT
on the top of your code module or declare the variables using

Code:
dim x as integer 
dim y as integer

Hope this helps!!
 
Back
Top