干脆把失去焦点的 lostfocus中改成如下了:
LOCAL tmp_1
IF "
-
" # this.Value
tmp_1 = INT(VAL(SUBSTR(this.Value,1,4)))
IF
tmp_1<1000
DO CASE
CASE tmp_1 < 50
tmp_1=tmp_1+2000
CASE tmp_1 >=50 AND tmp_1 < 100
tmp_1=tmp_1+1900
CASE tmp_1>=100
tmp_1=tmp_1+2000
ENDCASE
this.Value=STUFF(this.Value,1,4,ALLTRIM(STR(tmp_1)))
this.selstart=0
this.SelLength=4
this.SetFocus
ENDIF
tmp_1 = INT(VAL(SUBSTR(this.Value,6,2)))
IF VAL(SUBSTR(this.Value,6,2))>12
tmp_1=12
this.Value=STUFF(this.Value,6,2,ALLTRIM(STR(tmp_1)))
this.SelStart=5
this.SelLength=2
this.SetFocus
ELSE
IF tmp_1<=0
tmp_1=1
ENDIF
this.Value=STUFF(this.Value,6,2,PADL(tmp_1,2,"0"))
ENDIF
ENDIF