VB 怎么提取指定字符中的内容
比如提取[]中的内容:iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbh...
比如提取[]中的内容:
iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbhj[我啊不能兼顾噶额级别]jhasbdjhjaehujhejb[你看历史回顾IU感激不尽安静]hi回去啊U价格比较昂贵醋意[bjkhajhiuqahilhg]nbjklsabhjkbj
这是我瞎按的,不过还是可以作为参考的
我要所有[]中的内容,不只是第一个[],是所有[]中的内容 展开
iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbhj[我啊不能兼顾噶额级别]jhasbdjhjaehujhejb[你看历史回顾IU感激不尽安静]hi回去啊U价格比较昂贵醋意[bjkhajhiuqahilhg]nbjklsabhjkbj
这是我瞎按的,不过还是可以作为参考的
我要所有[]中的内容,不只是第一个[],是所有[]中的内容 展开
展开全部
Dim Ystr As String
Dim Tstr() As String
Dim n As Integer
Dim YesNo As Boolean
Dim Lstr As String
Dim i As Integer
Ystr = "iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbhj[我啊不能兼顾噶额级别]jhasbdjhjaehujhejb[你看历史回顾IU感激不尽安静]hi回去啊U价格比较昂贵醋意[bjkhajhiuqahilhg]nbjklsabhjkbj"
n = 0
YesNo = False
For i = 1 To Len(Ystr)
If Not YesNo Then
If Mid(Ystr, i, 1) = "[" Then
Lstr = Mid(Ystr, i, 1)
YesNo = True
End If
Else
Lstr = Lstr & Mid(Ystr, i, 1)
If Mid(Ystr, i, 1) = "]" Then
n = n + 1
ReDim Preserve Tstr(n) As String
Tstr(n) = Lstr
YesNo = False
End If
End If
Next i
For i = 1 To UBound(Tstr)
Debug.Print Tstr(i)
Next i
Dim Tstr() As String
Dim n As Integer
Dim YesNo As Boolean
Dim Lstr As String
Dim i As Integer
Ystr = "iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbhj[我啊不能兼顾噶额级别]jhasbdjhjaehujhejb[你看历史回顾IU感激不尽安静]hi回去啊U价格比较昂贵醋意[bjkhajhiuqahilhg]nbjklsabhjkbj"
n = 0
YesNo = False
For i = 1 To Len(Ystr)
If Not YesNo Then
If Mid(Ystr, i, 1) = "[" Then
Lstr = Mid(Ystr, i, 1)
YesNo = True
End If
Else
Lstr = Lstr & Mid(Ystr, i, 1)
If Mid(Ystr, i, 1) = "]" Then
n = n + 1
ReDim Preserve Tstr(n) As String
Tstr(n) = Lstr
YesNo = False
End If
End If
Next i
For i = 1 To UBound(Tstr)
Debug.Print Tstr(i)
Next i
展开全部
Private Sub Command1_Click()
Dim str As String, i As Long, strs() As String
str = "iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbhj[我啊不能兼顾噶额级别]jhasbdjhjaehujhejb[你看历史回顾IU感激不尽安静]hi回去啊U价格比较昂贵醋意[bjkhajhiuqahilhg]nbjklsabhjkbj"
strs() = Split(str, "[")
For i = 1 To UBound(strs)
Debug.Print Left(strs(i), InStr(strs(i), "]") - 1)
Next i
End Sub
Dim str As String, i As Long, strs() As String
str = "iegiuhrjknbe.walhio[jkgshaugui]bhsagyueajbdnbs,u[kauyuibaqjbcu]nbagajshvbhj[我啊不能兼顾噶额级别]jhasbdjhjaehujhejb[你看历史回顾IU感激不尽安静]hi回去啊U价格比较昂贵醋意[bjkhajhiuqahilhg]nbjklsabhjkbj"
strs() = Split(str, "[")
For i = 1 To UBound(strs)
Debug.Print Left(strs(i), InStr(strs(i), "]") - 1)
Next i
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询