如何将以逗号分割的字符串删除一个字符

liushiying 2006-05-18 11:08:58
有两个变量
aa="123,364,478,364,890,432"
bb="364"
如何将aa改成"123,478,364,890,432"
...全文
399 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
水如烟 2006-05-19
  • 打赏
  • 举报
回复
楼主的真实意图,可能是取键字符串.
任给一字串,比如"A,BV,D,A,C,F,D",得到结果"A,BV,D,C,F";
没必要是得到这样的结果吧"BV,A,C,F,D"
sz_lgp 2006-05-19
  • 打赏
  • 举报
回复
dim xx as string()
xx=aa.spilt()///aa="123,364,478,364,890,432"
dim m as integer
dim yy as string
bb="364"

for m=0 to xx.GetUpperBound(0)
if xx(m)=bb then
xx(m)=""
exit for
endif
endfor

for m=0 to xx.GetUpperBound(0)
if xx(m)<> "" then yy+=xx(m)& ","
endfor
alanzhou 2006-05-19
  • 打赏
  • 举报
回复

aa = "," & aa & ","
bb = "," & bb & ","

aa = aa.Replace(bb,",")

aa = aa.Substring(1,aa.length-1) //就是去掉头尾的两个","
iegrhn 2006-05-19
  • 打赏
  • 举报
回复
小心你的,和,
daisi 2006-05-19
  • 打赏
  • 举报
回复
删除一个字符串还差不多
viena 2006-05-19
  • 打赏
  • 举报
回复
晕,是“删除一个字符”吗?
HALOcn 2006-05-19
  • 打赏
  • 举报
回复
UP~~~```
mooninglover 2006-05-19
  • 打赏
  • 举报
回复
vb风格的,呵呵~~~~~

Dim aa As String = "123,364,478,364,890,432"
Dim bb As String = "364"
Dim iPos As Integer

iPos = aa.IndexOf("," & bb)
aa = aa.Substring(0, iPos) & aa.Substring(iPos + bb.Length + 1)
MsgBox(aa)
why2002plus 2006-05-18
  • 打赏
  • 举报
回复
length+1,哈,还有个逗号。
kssys 2006-05-18
  • 打赏
  • 举报
回复
这么晚了,发现各位都是夜猫子
kssys 2006-05-18
  • 打赏
  • 举报
回复
直接:aa=aa.Replace("364,","")
if aa.LastIndexOf(",364")<>-1 再把最后面的那个",364"删掉即可。
why2002plus 2006-05-18
  • 打赏
  • 举报
回复
Dim SearchWithinThis As String = "123,364,478,364,890,432"
Dim SearchForThis As String = "364"
Dim FirstCharacter As Integer = SearchWithinThis.IndexOf(SearchForThis)
Dim result = SearchWithinThis.Remove(FirstCharacter, SearchForThis.Length)
试试

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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