读书人

关于字符的取值解决方案

发布时间: 2012-03-07 09:13:51 作者: rapoo

关于字符的取值
举例:我爱你们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 } )

ArgumentDescription
string1The string in which you want to find string2.
string2The 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截取

读书人网 >PB

热点推荐