View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default boolean variable?

Steve,

While I gave you the answer you were after in my direct reply to your
original message, I want to fully endorse Per's suggested approach...
without question, it would be the best way for you to proceed.

--
Rick (MVP - Excel)


"Per Jessen" wrote in message
...
Hi Steve

I would not rely on the user to enter True or False, just use a msgbox to
answer yes or no, and then turn the answer to at boolean value:

Dim MyVar As Boolean
Answer = MsgBox("Is this a font color?", vbYesNo + vbQuestion, "True or
False")
If Answer = vbYes Then MyVar = True
'A boolean varieble is false by default

Regards,
Per

"Steve" skrev i meddelelsen
...
Howdee all.
I have a macro that I've got a variable that presently requires either a
true, or false input.
This macro calls to another function, which only requires an input if the
element is true.
I'd like it to only require an input if the statement is true.

I just tried-

MyVar = Application.InputBox(Prompt:="Is this a font color?- True or
False",
Type:=4)

If MyVar= "" Then
MyVar = False
Else: MyVar = True
End If

I receive a type mismatch error when I do this.