7,763
社区成员
发帖
与我相关
我的任务
分享
Dim strLine As String, strItem() As String
strLine = "21:19:08:0000000"
strItem = Split(strLine, ":")
ReDim Preserve strItem(2)
strLine = Join(strItem, ":")
2.Dim strLine As String, p As Integer
strLine = "21:19:08:0000000 "
p = InStrRev(strLine, ":")
strLine = Left(strLine, p - 1)
Left("21:19:08:000000",8)
Debug.Print Left$("21:19:08:000000", InStrRev("21:19:08:000000", ":") - 1)
注意你的那个字符串中的冒号,是“中文的冒号”(也不知道是不是因为你的输入法造成的)。
如果你确定你返回的值都是中文冒号,InstrRev()函数的第2个参数就要用中文冒号。反之,就必须用英文冒号。
如果不确定是中文冒号还是西文冒号(比如:可能是“两种都有”、混合的),就要用这样的代码:
Debug.Print Left$("21:19:08:000000", InStrRev("21:19:08:000000", ":", , vbTextCompare) - 1)