Re: problem with variable
- From: "Alexandre" <news.microsoft.com>
- Date: Wed, 6 Jul 2005 21:58:58 -0300
Duane Bozarth,
Thanks for the response.
"Duane Bozarth" <dpbozarth@xxxxxxxxxxxx> escreveu na mensagem
news:42CC7AFF.5B516E95@xxxxxxxxxxxxxxx
> Duane Bozarth wrote:
>>
>> Alexandre wrote:
>> >
>> > Hi
>> >
>> > I have a strange problem that I would appreciate any help
>> >
>> > Dim a1 As Currency
>> > Dim a2 As Currency
>> >
>> > a1 = a2 = 0
>> >
>> > ' result: a1 = -1 ???
>> >
>> > ' result: a2 = 0
>> >
>> > Why A1 = -1 ?
>> >
>> > Thanks & Regards,
>>
>> Because there is no multiple assignment in VB (and because the logical
>> equality operator is the same as the assignment operator it's possible
>> to misread the meaning easily).
>>
>> a1 = a2 = 0 actually means
>>
>> a1 = (a2 = 0)
>>
>> Since variables in VB are (guaranteed) initialized to 0 on creation, a2
>> ==0 so a1 is True and True is numerically -1 (all bits set).
>
> And, btw, shows the willingness of VB to coerce types as needed
> sometimes when you really would rather (or at least would be better off
> if) it didn't...
.
- Follow-Ups:
- Re: problem with variable
- From: J French
- Re: problem with variable
- References:
- problem with variable
- From: Alexandre
- Re: problem with variable
- From: Duane Bozarth
- Re: problem with variable
- From: Duane Bozarth
- problem with variable
- Prev by Date: Re: problem with variable
- Next by Date: Re: simple counter variable.
- Previous by thread: Re: problem with variable
- Next by thread: Re: problem with variable
- Index(es):
Relevant Pages
|
Loading