|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
If statement evaluation problem
In the If statement below, the criteria always evaluates to false in running code. If I paste the criteria in the immediate window and hit enter, it evaluates to true. The Coils object is an ADODB recordset connected to a DB/2 database (i think...its our AS400 Business system). I've also tried float(u'10') on the right side of the operator, but that doesn't work either (in the running code. any of this works in the immediate window). Any ideas on whats wrong?
Code:
if (float(self.Coils.Fields("csbfnb").Value) >= float(10)):
self.Inventory.Fields("width").Value = float(self.Coils.Fields("csb6nr").Value)
else:
self.Inventory.Fields("width").Value = float(self.Coils.Fields("csbfnb").Value)
|
|
#2
|
|||
|
|||
|
Nevermind. I'm not sure what I was doing wrong before, but if i put float(u'10') on the right side, it works.
|
|
#3
|
|||
|
|||
|
Instead of float(10) or float(u'10') you could just use 10.0.
However, are you sure the type of Coils.Fields("csbfnb").Value is a float? If it was a string, the comparision would still work, but a string always compares as greater than a float. Dave - The Developers' Coach |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > If statement evaluation problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|