当前位置: 代码迷 >> PB >> 关于字符的取值解决方案
  详细解决方案

关于字符的取值解决方案

热度:89   发布时间:2016-04-29 08:57:28.0
关于字符的取值
举例:我爱你们5a(哈哈)朋友

怎么取(前的字符

即要得到的值:我爱你们5a

------解决方案--------------------
//sle_1.text=我爱你们5a(哈哈)朋友 
string ls_ls
ls_ls=mid(sle_1.text,1,10)
MessageBox('提示',string(ls_ls))
//mid(string,start{, length})
//从string中第start开始,取长度为length的子串。
------解决方案--------------------
int nPos
string yourStr,getStr
nPos= pos(yourStr,"(")// you can try posW for double byte charset string
if nPos>0 then 
getStr = left(yourStr,nPos-1)
end if
------解决方案--------------------
pos就可以定位到了

Description 

Finds one string within another string.
PosW A separate function provides an alternative syntax for DBCS environments. 

Syntax 

Pos ( string1, string2 {, start } )

PosW ( string1, string2 {, start } )

Argument Description
string1 The string in which you want to find string2.
string2 The string you want to find in string1.
start 
(optional) A long indicating where the search will begin in string1. The default is 1.
Return value 

Long. Returns a long whose value is the starting position of the first occurrence of string2 in string1 
after the position specified in start. If string2 is not found in string1 or if start is not within string1, Pos
 returns 0. If any argument's value is null, Pos returns null.


------解决方案--------------------
POS定位,MID截取
  相关解决方案