pos()函数

nettt 2010-01-07 04:59:29
一个比较弱的问题。
string linedata
int pos ,temppos
linedata="ab,cd,ef,gh,"
pos = pos(linedata, ",")
//我用这个只能取出第一个,的位置
我怎么才能得到第二个第三的位置
...全文
838 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
nettt 2010-01-07
  • 打赏
  • 举报
回复
乌龟 是谁呀
nettt 2010-01-07
  • 打赏
  • 举报
回复
string linedata
int temppos,pos
linedata="A,Caaa,aaaD,F"
pos = pos(linedata, ",", 1)
temppos = pos(linedata, ",", temppos + 1)
temppos = pos(linedata, ",", temppos + 1)
temppos = pos(linedata, ",", temppos + 1)
//我刚刚查了一个POS还有一个参数,就是Pos ( string1, string2 {, start } )
中的start,这样就不用循环了
不知道对不对,我对temppos + 1并不太理解,这是我凭感觉蒙的,不过也能达到我要的效果
我想请高手 指点一下这第三个参数是什么意思
nettt 2010-01-07
  • 打赏
  • 举报
回复
在CSDN上学东西真是快呀
nianran520 2010-01-07
  • 打赏
  • 举报
回复
呃 乌龟你无处不在
nettt 2010-01-07
  • 打赏
  • 举报
回复
真是历害,马上给分
nianran520 2010-01-07
  • 打赏
  • 举报
回复
string linedata 
int pos=0 ,temppos
linedata="ab,cd,ef,gh,"
do while pos(linedata, ",",pos+1)>0
pos = pos(linedata, ",",pos+1)
loop
dawugui 2010-01-07
  • 打赏
  • 举报
回复
要使用循环加数组来实现.
大致为
long sz[]
long i = 0
string linedata
int pos ,temppos
linedata="ab,cd,ef,gh,"
do while pos(linedata, ",") > 0
i = i + 1
sz[i] = pos(linedata, ",")
linedata = mid(linedata,pos(linedata, ",") + 1 ,len(linedata))

最后循环获取数组中的值.
for i = 1 to UpperBoun(sz)
messagebox("",sz[i])
end for
nettt 2010-01-07
  • 打赏
  • 举报
回复
一条语句能不能搞定
xuam 2010-01-07
  • 打赏
  • 举报
回复
循环!

740

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧