作者:csyx
?CHRTRAN("a,b,c,d,e,f", "abcdef", "123456")
clear
cstr="abc32skfkj262ksf8k99kfsk24kf"
cstr1=""
ncount=0
nsum=0
ok=.f.
for i=1 to len(cstr)
a=substr(cstr,i,1)
if isdigit(a)=.t.
cstr1=cstr1+a
ok=.t.
else
if ok=.t.
nsum=nsum+val(cstr1)
cstr1=""
ok=.f.
...
作者:十豆三
*--文本文件的编码格式手动查看方法:
*--用记事本打开文本后,点击菜单上的“另存为”,编码格式在出现的对话框下方。
*--那用VFP如何取得文本文件的编码格式呢,如下:
lcFileName='C:/A.txt' &&文本文件名
lcStr=Filetostr(lcFileName)
lcStrType=Createbinary(Substr(lcStr,1,2))
Do Case
Case lcStrType=0hEFBB &&VFP6.0不支持此种方式,此实列是在VFP9....
方法一(VFP方法)
Clear
cStr=Strtran(Filetostr("demon.txt"),0h0d0a,"|")
Do While "||"$cStr
cStr=Strtran(cStr,"||","|")
Enddo
=Strtofile(Strtran(Substr(cStr,2),"|",0h0d0a),"demon1.txt")
方法二(正则表达式方法)
clear
local Reg, cStr
Reg = CreateObject("VBScript.RegExp")
c...
说明:&T为一间店铺的开始,&P为一间店铺的结束,&L为一条记录的结束
Create Cursor TEST (Shopno C(10),Shopname C(30),Pos C(10),Card C(20),Amt N(10,2),Hkfee N(10,2),seq C(10),Date1 C(8) ,Time C(6))
nRow=ALines(AcStr,FileToStr("Wt.Txt"),1,Chr(13)+Chr(10))
For lnI=1 To nRow
cStr=AcStr[lnI]
...
cStr="a b c d" && 变为 "a b c d"
Do While Space(2)$cStr
cStr=Strtran(cStr,Space(2),Space(1))
EndDo
MessageBox(cStr)
lcStr="A1]中国"
?Strconv(lcStr,2)
结果:A1]中国
然后通过For EndFor方法提取出汉字
CSTR=[103]
A=CSORT(CSTR)
LIST MEMORY LIKE A
FUNCTION CSORT(AA)
PUBLIC ASTR(LEN(AA))
FOR I=1 TO LEN(AA)
ASTR(I)=SUBSTR(AA,I,1)
ENDFOR
=ASORT(ASTR)
RETURN @ASTR
CSTR="我想將一BC個字123456符串分割G成兩行"
MESSAGEBOX(FUN(CSTR),64,[系统信息])
*--- 自定义函数
FUNCTION FUN
PARAMETERS CSTR
LOCAL NLEN
NLEN=LEN(CSTR)/2
CSTR_1=LEFT(CSTR,NLEN)
NLEN=IIF(STRCONV(STRCONV(CSTR_1,5),6)==CSTR_1,NLEN,NLEN+1)
RETURN LEFT(CSTR,NLEN)+CHR(10)+CHR(13)+CHR(10)+SUBSTR(CSTR,NLEN+1)
下面一段数据,要求遇到字母时开始换行。如何做到?
B0F0090504210807000220202020024033080000080000180A09021309032909021909021900011000000000ED21080700000000000800000000651056000000000380032000000244000000000000000000000898B4032108070000000000080000010890A887210807090224090224
换行后变成下面
B0F009050421080...
* 字符串"A1 A2 A3 A4 A5 A6"转换成"A1,A2,A3,A4,A5,A6"
lcstr="A1 A2 A3 A4 A5 A6"
lcstr=chrtran(lcstr," ",",")
do while ",,"$lcstr
lcstr=strtran(lcstr,",,",",")
enddo
messagebox(lcstr)
*一串不重复的数字,并且从小到大排列,如何比较快捷的判断出其中有哪几组数字是连续的,并且取出每组的两头值?
*如:1,3,6,8,9,10,12,15,20,23,24,25,26,30,33,34,35,36,37,38,39,40
*变成:1,3,6,8-10,12,15,20,23-26,30,33-40
Clear
lcStr="1,3,6,8,9,10,12,15,20,23,24,25,26,30,33,34,35,36,37,38,39,40"
nRow=Alines(Astr,Strtran(lcStr,",",Chr(13)+Chr(10)))
l...