2,718
社区成员
发帖
与我相关
我的任务
分享
Private xx,yy,i
xx=''
str1=Alltrim(Thisform.text1.Value)
For i=1 To Len(str1)
If Substr(str1,i,1) $ ('0123456789')
xx=xx+Substr(str1,i,1)
Endif
Endfor
thisform.text2.Value=xx
VFP代码,已经测试过!
*测试环境:VFP 8.0
Local lcText_Value as String &&文本框内容
Local lnText_Value_Len as Integer &&文本框内容的长度
Local lnStart_Pos as Integer &&数字起始位置
Local lnEnd_Pos as Integer &&数字结束位置
Local lnLoop as Integer &&循环
With thisform.text2
cText_Value = Alltrim(.Value)
lnText_Value_Len = Len(cText_Value)
For lnLoop = 1 to lnText_Value_Len step 1
If Substr(cText_Value, lnLoop, 1) $ "0123456789"
lnStart_Pos = lnLoop
Exit for
Endif
Endfor
.SelStart = lnStart_Pos - 1
For lnLoop = lnStart_Pos to lnText_Value_Len step 1
If not(Substr(cText_Value, lnLoop, 1) $ "0123456789")
lnEnd_Pos = lnLoop
Exit for
Endif
Endfor
.SelLength = lnEnd_Pos - lnStart_Pos
Endwith