6
 If TextBox1.Text = "" Or TextBox1.Text = "False" Then
        msgbox("Filename invalid. Try again.",vbOKOnly)

I'm getting "Compiler Error: Expected: =" error message.

3
  • I have never used VBA, but I would guess you want ==. Commented Apr 15, 2012 at 2:47
  • @jordanm: No. Visual Basic is sane and the correct comparison operator is = ;) Commented Apr 15, 2012 at 2:48
  • @jordanm: Pretty sure it's =. == is used in C++ variant languages if I recall correctly. Commented Apr 15, 2012 at 2:48

1 Answer 1

19

It's because you can only call Subs either with Call or without parentheses in VBA. So change it to:

MsgBox "Filename invalid. Try again.", vbOKOnly

Or, if you like this style better:

Call MsgBox("Filename invalid. Try again.", vbOKOnly)

(And the reason you get the error is because it expects you to assign the result to a variable, hence it expects an =.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.