a=1234.567800
a=alltrim(padl(a,20," ")) &&VFP中数值型数据有效长度不会超过20位
? "整数位数:",len(JUSTSTEM(a))
? "小数位数:",len(JUSTEXT(a))
CLEAR
cStr="第一百零七章 好事多磨"
=ALINES(Astr,cStr,"第","章")
nLen=0
cLstr=""
cRstr=""
cStr1=astr[2]
* 左取两个字符
IF LEFT(cStr1,2)="十" AND LEN(cStr1)>2
cLstr="1"
cStr1=cLstr+SUBSTR(astr[2],3)
ENDIF
* 右取两个字符
DO CASE
CASE RIGHT(cStr1,2)="十" AND LEN(cStr1)=2
cRstr="10"
...
以DBF文件为例
create cursor tt (vfile c(20))
ncnt=adir(aa,"*.dbf")
b=1
append from array aa[b,1]
browse
list memory like aa
有这么一个数值型数据
Num=2015.02
转换为日期型数据:2015-02-01
Set Date Ansi
Set Century ON
Set Mark To "-"
? Date(Int(Num),(Num-Int(Num))*100,1)
? Date(Int(Num),mod(Num*100,100),1)
a="1,2,3,4"
?evaluate(chrtran(a,",","+"))
Clear
Rand(-1)
lnNum=10 &&生成随机数个数
Dimension nStr[lnNum]
N=0
Do While n<lnNum
nItem = Ceiling(lnNum*Rand())
If Ascan(nStr,nItem)=0
nStr[N+1]=nItem
N=N+1
EndIf
EndDo
For Each nVar In nStr[lnNum]
? nVar
EndFor
方法...
NOTE 区位码生成程序
CREATE CURSOR T (S N(2))
FOR I=1 TO 94
INSERT INTO T VALUES (I)
ENDFOR
SELECT PADL(A.S,2,[0])+PADL(B.S,2,[0]) AS QWM,CHR(160+A.S)+CHR(160+B.S) HZ,;
TRANSFORM(ASC(CHR(160+A.S)+CHR(160+B.S))) NASC FROM T A INNER JOIN T B ON A.S<=B.S OR A.S>B.S
? quling(123.00)
? quling(123.100)
? quling(123.010)
function quling
Parameters lenum
lcnum=alltrim(padl(lenum,16," "))
do while right(lcnum,1)="0"
lcnum=left(lcnum,len(lcnum)-1)
enddo
if len(justext(lcnum))=0
lcnum=chrtran(lcnum,".","")
endif
return lcnum