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
 
As many as you like :-
If catsLoveDogs = True And dogsLoveCats = False Then
 
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
 

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