現有一個dbf檔案,里面有2個欄位,一個lin_zhon_1,一個是ldlx。我現在想根據lin_zhon_1的值不同,對ldlx填入不同的值。
寫了一個小程式,但是都是替換失敗,依然還是空值。求大神解答下
代碼如下:
use?
set talk off
REPLACE all lin_zhon_1 with IIF(EMPTY(lin_zhon_1),"0",lin_zhon_1)
GO top
scan
DO CASE
CASE VAL(allt(lin_zhon_1))<118 and VAL(allt(lin_zhon_1))>110
REPLACE all ldlx with "10"
CASE VAL(allt(lin_zhon_1))<128 and VAL(allt(lin_zhon_1))>120
REPLACE all ldlx with "20"
CASE VAL(allt(lin_zhon_1))<234 and VAL(allt(lin_zhon_1))>230
REPLACE all ldlx with "30"
CASE VAL(allt(lin_zhon_1))=240
REPLACE all ldlx with "40"
CASE VAL(allt(lin_zhon_1))<256 and VAL(allt(lin_zhon_1))>250
REPLACE all ldlx with "50"
OTHERWISE
REPLACE all ldlx with ""
ENDCASE
ENDSCAN
GO top
scan
DO CASE
CASE lin_zhon_1="0" and VAL(allt(di_lei_1))<199
REPLACE all ldlx with "70"
CASE lin_zhon_1="0" and VAL(allt(di_lei_1))>260
REPLACE all ldlx with "70"
ENDCASE
ENDSCAN
uj5u.com熱心網友回復:
把 所有的 REPLACE all 中去掉 ALL 看看怎樣!uj5u.com熱心網友回復:
+1
uj5u.com熱心網友回復:
或者去掉 scan ... endscan,三次 replace all 即可Replace all lin_zhon_1 with Evl(lin_zhon_1, "0") && 這條也可不要
Replace all ldlx with ICase( ;
110 < Val(lin_zhon_1) and Val(lin_zhon_1) < 118, "10" ;
,120 < Val(lin_zhon_1) and Val(lin_zhon_1) < 128, "20" ;
,230 < Val(lin_zhon_1) and Val(lin_zhon_1) < 234, "30" ;
,240 = Val(lin_zhon_1), "40" ;
,250 < Val(lin_zhon_1) and Val(lin_zhon_1) < 256, "50", "0")
Replace all ldlx with "70" For lin_zhon_1 = "0" and (Val(di_lei_1) < 199 or Val(di_lei_1) > 260)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/96631.html
標籤:VFP
