特定字符提取!发分!!

myhwlj 2004-06-09 10:49:43
在文本内+信息+,得到指定部分的字符串,就是得到到++中间的部分

adfasssadfafasdasf+dir+fasdfsssfsf
怎么才能提取出dir来。谢谢
...全文
167 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
LanceJin 2004-06-09
  • 打赏
  • 举报
回复
up
BlueBeer 2004-06-09
  • 打赏
  • 举报
回复
test="adfasssadfafasdasf+dir+fasdfsssfsf"
?mid(test,instr(test,"+")+1,instrrev(test,"+")-(instr(test,"+")+1))
dir
weaest 2004-06-09
  • 打赏
  • 举报
回复
split(s,"+")
flyingscv 2004-06-09
  • 打赏
  • 举报
回复
lstart=instr(s,"+")
lend=instr(start+1,s,"+")
print mid(s,lstart,lend-lstart+1)
ryuginka 2004-06-09
  • 打赏
  • 举报
回复
来晚了,就学习
huangjianyou 2004-06-09
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim strArray() As String
strArray = Split("adfasssadfafasdasf+dir+fasdfsssfsf", "+")
MsgBox strArray(1)
End Sub
flyingscv 2004-06-09
  • 打赏
  • 举报
回复
楼主真大方啊,我都好意思了

1 InStr Function

Returns a Variant (Long) specifying the position of the first occurrence of one string within another.

Syntax

InStr([start, ]string1, string2[, compare])


2 Mid Function


Returns a Variant (String) containing a specified number of characters from a string.

Syntax

Mid(string, start[, length])


northwolves 2004-06-09
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim txt As String
txt = "adfasssadfafasdasf+dir+fasdfsssfsf"
MsgBox Split(txt, "+")(1) 'method 1
Mid(txt, 1, InStr(txt, "+")) = String(Len(txt), " ")
Mid(txt, InStrRev(txt, "+")) = String(Len(txt), " ")
txt = Trim(txt) 'method 2
MsgBox txt
End Sub
liujingxiong 2004-06-09
  • 打赏
  • 举报
回复
上面的朋友在开玩笑吧,怎么能查找"dir"?"dir"的部分是会变化的,如果知道的话就不用提取了。
flyingZFX 2004-06-09
  • 打赏
  • 举报
回复
dim tempSTR as string
dim a as string

tempSTR="adfasssadfafasdasf+dir+fasdfsssfsf"

a=Mid(tempSTR,InStr(1,tempSTR,"dir"),3)
myhwlj 2004-06-09
  • 打赏
  • 举报
回复
今天4:30结贴
wooin 2004-06-09
  • 打赏
  • 举报
回复
用Split()但还要自己写一些,来晚了。。。蹭点分吧。。。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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