VB 截取字符
发布网友
发布时间:2022-05-05 22:46
我来回答
共6个回答
热心网友
时间:2022-06-28 06:02
1个text1,1个Command1
'把那些文字复制到text1 'Text1.MultiLine = True
Private Sub Command1_Click()
Dim i As Integer, j As Integer
Dim str1, str2
i = 1
str1 = Split(Text1.Text, "cropGrow value=")
For i = 1 To UBound(str1) '忽略掉下标为0的
str1(i) = Mid(str1(i), InStr(1, str1(i), """") + 1)
str1(i) = Left(str1(i), InStr(1, str1(i), """") - 1)
str2 = Split(str1(i), ",")
For j = 0 To UBound(str2) - 1 '忽略掉最后的2000000000
Debug.Print str2(j),
Next j
Debug.Print
Next i
End Sub
热心网友
时间:2022-06-28 06:03
Private Declare Function icePub_getSubString Lib "icePubDll.dll" (ByVal strText As String,ByVal strResult As String,ByVal strBegin As String,ByVal strEnd As String,ByVal startIndex As Integer) As Integer
Dim a2 As Integer
Dim strText As String
Dim strSubText As String
'strText="<body>"+vbCrLf +"<p>welcome~"+vbCrLf +"</body>"
'strText赋值成上边页面代码文本
strSubText=Space(1024+1)
a2=icePub_getSubString(strText,strSubText,"<cropGrow value=",",2000000000",0)
MsgBox strSubText
参考资料:http://bbs.icese.net/icepubdll/icePubDLL%bd%d2%c3%d820110713.pdf
热心网友
时间:2022-06-28 06:03
mid函数和len函数配使用就可以了,自己查一下
热心网友
时间:2022-06-28 06:04
用Split +一个循环可以解决
'strText赋值成上边页面代码文本
sp_str=split(strtext,",2000000000")
for i=0 to ubound(sp_str)-1
a1=instr(sp_str(i),"<cropGrow value=")+len("<cropGrow value=")'
list1.additem left(sp_str(i),len(sp_str(i))-a1) '加入list
next
热心网友
时间:2022-06-28 06:05
Sub GetStr(HtmlStr$, StrPublic$, StrBg$, StrEnd$)
On Error GoTo aa
Dim RltStr$
a = InStr(HtmlStr, StrPublic)
b = Mid(HtmlStr, a, Len(HtmlStr) - a)
Do While b > 0
c = InStr(b, StrBg): d = InStr(c + 1, b, StrEnd)
RltStr = Mid(b, c + Len(StrBg), d - c - Len(StrBg))
List1.AddItem RltStr
a = InStr(d, b, StrPublic)
b = Mid(b, a, Len(b) - a)
Loop
aa:
End Sub
Private Sub Command1_Click()
Dim HtmlStr$, StrPublic$, StrBg$, StrEnd$
HtmlStr = "你给出的源码"
StrPublic = "<cropGrow"
StrBg = "value="""
StrEnd = ",2000000000"
Call GetStr(HtmlStr, StrPublic, StrBg, StrEnd)
End Sub
热心网友
时间:2022-06-28 06:05
是只要这一行吗? 还是只要svchost.exe 开头,带个数字的都要?
只要这一行的代码:
新建工程,2个文本框,text1中放你上在这段文本,text2中显示找到的字符串:
Private Sub Command1_Click()
FindStrS = "svchost.exe"
FindStrE = "DcomLaunch,"
i = InStr(Text1, FindStrS)
If i > 0 Then
j = InStr(i + 1, Text1, FindStrE)
If j > 0 Then Text2 = Mid(Text1, i, j - i) & FindStrE
End If
End Sub