也许有一天 发表于 2020-9-23 21:49:44

请问一下,为什么数值之间的大小比较不出来,是变量属性的问题吗?变量及判断结果如图

    ccccc = rs.Fields(26)


   If (ccccc) = 0 Then
    mohao_y(0) = (a - startmileage) * 240 / onepagemileage + stpp(0): mohao_y(1) = 0 + yl_stpp(1) - height
    mohao_y(2) = (b - startmileage) * 240 / onepagemileage + stpp(0): mohao_y(3) = 0 + yl_stpp(1) - height
    mohao_y(4) = (b - startmileage) * 240 / onepagemileage + stpp(0): mohao_y(5) = 0 + yl_stpp(1) - height
    mohao_y(6) = (a - startmileage) * 240 / onepagemileage + stpp(0): mohao_y(7) = 0 + yl_stpp(1) - height
   Set Ld7(0) = AcadDoc.ModelSpace.AddLightWeightPolyline(mohao_y)


   Else

          If 0 < ccccc <= 1 Then
   R = 250
   d = 194
   d1 = 249
      ElseIf 1 < ccccc <= 2 Then
   R = 255
   d = 122
   d1 = 242
    ElseIf 2 < ccccc <= 3 Then
   R = 255
   d = 66
   d1 = 236
   ElseIf 3 < ccccc <= 4 Then
      R = 250
   d = 0
   d1 = 235
    ElseIf 4 < ccccc <= 5 Then
   R = 209
   d = 6
   d1 = 188
    ElseIf 5 < ccccc <= 6 Then
   R = 173
   d = 0
   d1 = 156
    ElseIf ccccc > 6 Then
   R = 133
   d = 0
   d1 = 117
   End If
    Print ccccc & "       " & RGB_R & "      " & d1 & "   " & d

sgwsssxm 发表于 2020-9-23 22:08:33

VBA语法不支持 If 0 < ccccc <= 1 Then 这种区间比较的形式,改成 If 0 < ccccc And ccccc <= 1 Then 就行了。

也许有一天 发表于 2020-9-24 09:56:25

sgwsssxm 发表于 2020-9-23 22:08
VBA语法不支持 If 0 < ccccc

好的,非常感谢
页: [1]
查看完整版本: 请问一下,为什么数值之间的大小比较不出来,是变量属性的问题吗?变量及判断结果如图