Testing a string > "" is a valid way to test for a non-null variable IMO. If you think about it a string can never be < "". Am not aware of a language, p-code or otherwise, where that is not the case.
Brett "Brian Leach" <[email protected]> wrote in message news:<[email protected]>... > var1.Field(1).StringValue > "" > > Do you mean that? Or do you mean var1.Field(1).StringValue <> "" ? > > Differences between the P-Code and fully compiled code have been a 'feature' > of VB for a long time - the compiled code is generally more accurate/less > forgiving and - whilst not relevant here - if you have any sort of > multithreading in your code, that can operate differently. > > If you are concerned, can you send out the P-Code executable? On today's > processors, the performance difference is unlikely to hurt. > > Brian > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Adrian Halid > Sent: 12 November 2010 02:18 > To: [email protected] > Subject: [U2] Val on UniDynArray produces unexpected results > > Hi All, > > We have come across a very strange bug between UniDynArray and VB6. > > In our applications we were getting two different results on an if statement > between the IDE and the compiled (into Native) exe. > > In the IDE case the statement was returning True which is correct. > In the compiled native exe the exact same statement was returning false > which is wrong as the statement should evaluate to true. > If we compiled the exe into p-code then the statement evaluates to True as > it should. > > The conditional statement seems to have to be in this exact structure (kind > of like a perfect storm of conditions). > > ((var1.Field(1).StringValue > "") Or (False And > Val(var1.Field(2).StringValue) > 0)) > > It must compare the same UniDynArray in each part of the if statement and > perform a Val on the second UniDynArray. > > The issue can be demonstrated by the sample code below. > We have two Booleans (b1 and b2) that should always evaluate to true. > In the VB6 IDE b1 is true and b2 is true as expected. > In the Compile Native exe b1 actually evaluates to false. (This is wrong b1 > and b2 should always be True). > > ---------------------------------------------------------------------------- > ----------------------------------- > Dim var1 As UniDynArray > Dim b1 As Boolean > Dim b2 As Boolean > > Set var1 = New UniDynArray > > var1.Field(1).StringValue = "1" > var1.Field(2).StringValue = "" > > ' b1 and b2 should always be True > ' When compiled into Native Code b1 is false and b2 is true. Why? > > b1 = ((var1.Field(1).StringValue > "") Or (False And > Val(var1.Field(2).StringValue) > 0)) > > b2 = ((False And Val(var1.Field(2).StringValue) > 0) Or > (var1.Field(1).StringValue > "")) > > MsgBox "b1=" & b1 & " and b2=" & b2 > > ---------------------------------------------------------------------------- > ----------------------------------- > > I know we can fix the problem quickly by swapping round the conditional > blocks or create new variables to hold the string values and then compare > them. > > My concern is that in our very large application what conditional statements > could be failing in the executable we send out. > > > > Regards > > Adrian Halid > Senior Analyst/Programmer > > IT Vision Australia Pty Ltd (ABN: 34 309 336 904) > PO Box 881, Canning Bridge WA 6153 > Level 3, Kirin Centre, 15 Ogilvie Road, Applecross, WA, 6153 > P: (08) 9315 7000 F: (08) 9315 7088 > E: [email protected]<mailto:[email protected]> > W: http://www.itvision.com.au<http://www.itvision.com.au/> > > > > ___________________________________________________________ > > NOTICE : This e-mail and any attachments are intended for the addressee(s) > only and may > contain confidential or privileged material. Any unauthorised review, use, > alteration, > disclosure or distribution of this e-mail (including any attachments) by an > unintended recipient > is prohibited. If you are not the intended recipient please contact the > sender as soon as > possible by return e-mail and then delete both messages. > ___________________________________________________________ > > > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users > > > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users > > This message contains information that may be privileged or confidential and is the property of GPM Development Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient ,you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. This e-mail was sent to you by GPM Development Ltd. We are incorporated under the laws of England and Wales (company no. 2292156 and VAT registration no. 523 5622 63). Our registered office is 6th Floor, AMP House, Croydon, Surrey CR0 2LX. _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
