• 主页

# 怎樣計算出在字符串中有多個豆號中的最后一個豆號在字符串中的位置???急﹗在線等 ....

chmz 2003-12-27 02:11:27

...全文
4 点赞 收藏 8

8 条回复

chmz 2003-12-27

yoki 2003-12-27
eg:
debug.print InStrRev("abc,de,f,g,h,j", ",")

InStrRev函数

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

zmcpu 2003-12-27
End Sub

zmcpu 2003-12-27
Dim str As String
Dim IntLen As Integer
IntLen = 1
Do Until InStr(1, str, ",", vbTextCompare) = 0
IntLen = IntLen + 1
str = Mid(str, 2)
Loop
MsgBox "最后一個豆號的位置:" & IntLen - 1

Dim str As String
Dim i, i1 As Integer
str = "sdf....sdafasf..sfd..dsf.sdf..f"
i = 1
Do While (i)
i1 = i
i = InStr(i + 1, str, ".", vbTextCompare)
Loop
MsgBox i1'i1 就是最后一个.的位置了
End Sub

rainstormmaster 2003-12-27

Private Sub Command2_Click()
Dim s As String
s = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o"
Dim s1 As String
s1 = ","
Dim i As Long
i = Len(s)
Dim arr As Variant
arr = Split(s, s1)
Dim j As Long
j = Len(arr(UBound(arr)))
Debug.Print "最后一个,的位置为" + CStr(i - j)
End Sub

rainstormmaster 2003-12-27
Private Sub Command1_Click()
Dim s As String
s = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o"
Dim s1 As String
s1 = ","
Dim i As Long
i = InStrRev(s, s1)
Debug.Print "最后一个,的位置为" + CStr(i)

End Sub

VB基础类

7450

VB 基础类