Re: problem with variable



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...


.



Relevant Pages

  • Re: problem with variable
    ... > Dim a1 As Currency ... Because there is no multiple assignment in VB (and because the logical ... equality operator is the same as the assignment operator it's possible ...
    (microsoft.public.vb.general.discussion)
  • Re: problem with variable
    ... >> Dim a1 As Currency ... > Because there is no multiple assignment in VB (and because the logical ... > equality operator is the same as the assignment operator it's possible ...
    (microsoft.public.vb.general.discussion)
  • Re: Fronten/Backend
    ... Dim wa As Long, wb As Long, wc As Integer, wd As Long, we As String, wf As ... Dim rStromverbr As Long, rEURWVerbr As Currency, rWasserverbr As Long, ... rWasservorauszlg As Currency ...
    (microsoft.public.de.access)
  • Re: AND Operator and Currency data type
    ... dblPRMValue) to Currency whose memory-representation ... Dim lngLoWord As Long, lngHiWord As Long, lngValue As Long ... Dim recCSResult As recUDCurrencyStructure ... LSet recDLLeftExpression = recCSLeftExpression ...
    (microsoft.public.vb.general.discussion)
  • Re: How can I time the speed of a macro?
    ... Do you have the class module in the same workbook, ... lpPerformanceCount As Currency) As Long ... Dim cFrequency As Currency ... Private Sub Class_Initialize ...
    (microsoft.public.excel.programming)

Loading