423,516 Members | 2,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,516 IT Pros & Developers. It's quick & easy.

Multiple Assignment Operator: Strange Problem

P: n/a
Could anyone give the reason why this is happening:
------------------------------------------------------
Dim a1, a2, a3, a4, a5, a6, a7, a8 as Integer
a1=a2=a3=a4=a5=a6=a7=a8=0
msgbox ("a1:" & a1) 'Here the value of a1 is -1 and values
of a2 thru a8 are 0
------------------------------------------------------
Dim a1, a2, a3, a4, a5, a6, a7, a8 as Integer
a1=a2=a3=a4=a5=a6=a7=0
msgbox ("a1:" & a1) 'Here the value of a1 is 0 and values
of a2 thru a7 are 0
------------------------------------------------------

Cant I initialize values of more than 7 variables at a
time?

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Pradeep,

If that were C# it would be fine. In VB you've got a single assignment (to
a1) or a very long Boolean expression.

'True, False, True, False, True, False, True!
a1 = ((((((a2=a3)=a4)=a5)=a6)=a7)=a8)=0 'True

'True, False, True, False, True, False!
a1 = (((((a2=a3)=a4)=a5)=a6)=a7)=0 'False

Regards,
Fergus
MVP [Windows Start button, Shutdown dialogue]
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.