Compile error when using Res=Inputbox

  • Thread starter Thread starter Corey
  • Start date Start date
C

Corey

res = InputBox("Please enter a Customer Name here", "....")
I get an error with this NOW?
Why?
How to fix?


Corey....
 
Compiles fine here. Did you paste it in (sometimes browsers use
non-breaking spaces to indent - deleting the whitespace removes the
error)?
 
The Compile error says:
Variable Not Defined?
I removed the Spaces but they return and the same error occurs.

Compiles fine here. Did you paste it in (sometimes browsers use
non-breaking spaces to indent - deleting the whitespace removes the
error)?
 
Corey,
That one line of code, as written, compiles.
Of course, you should be using Option Explicit, and then you would need to
Dim res.
There must be something else you are not including.

NickHK
 
That was it Nick.
I changed my project to Option Explicit
Yet did not dim res as variant

Thanks

Corey,
That one line of code, as written, compiles.
Of course, you should be using Option Explicit, and then you would need to
Dim res.
There must be something else you are not including.

NickHK
 
Then you need to define the variable...


Dim res As String

or

Dim res As Variant

You usually get that error when you have "Option Explicit" at the top of
your module. It's a GOOD thing. Keeps you from tearing your hair out
over thing like:

Dim result As String

'lots of code here

res = Inputbox("...")

'lots more code

If result = "foo" Then
'...

where result never gets assigned...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top