declare type and value on one line?

  • Thread starter Thread starter Jamie Martin
  • Start date Start date
J

Jamie Martin

Can I declare the type and the value of a variable on one line, such as

Dim sexy As Boolean = True

?

Also, can I do a two-condition test, like

If (catsLoveDogs = True) && (dogsLoveCats = False) Then
MsgBox("All is right with the world.")
End If

?
 
Multiple condiftion tests are allowed

Dim sexy As Boolean = True... did not work.

-Neil
 
You can do the first, only as a constant:

Const Sexy As Boolean = True

AND is the conjunction operator
OR is the disjunction operator

If (catsLoveDogs = True) AND (dogsLoveCats = False) Then
 
Jamie,

You can't initialize a variable in its declaration. The closest you can get
is to use the ":" character to put two logical lines of code on one actual
line of text. E.g.,

Dim sexy As Boolean : sexy = True
 
Back
Top