cutils.cls
来自「GPS测量数据处理源码」· CLS 代码 · 共 80 行
CLS
80 行
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CParseUtils"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
'Class name: CParseUtils.cls
Option Explicit
Friend Function CountParts(sString As String, Optional sDelim As String) As Byte
' 返回协议串中用","分割的节数
Dim textPos As Integer
Dim maxPos As Integer
Dim cnt As Integer
If Len(sDelim) = 0 Then sDelim = ","
If Len(sString) = 0 Then
CountParts = 0
Exit Function
End If
textPos = 1
maxPos = Len(sString)
cnt = 0
Do While textPos <= maxPos
If Mid$(sString, textPos, 1) = sDelim Then
cnt = cnt + 1
End If
textPos = textPos + 1
Loop
If cnt = 0 Then
CountParts = cnt
Else
CountParts = cnt + 1
End If
End Function
Friend Function Parse(ByVal sString As String, iReq As Integer, Optional sDelim As String) As String
'分割字符串内容
Dim sSt As String
Dim iCnt As Integer
Dim iPos As Integer
If Len(sDelim) = 0 Then sDelim = ","
sSt = sString & sDelim
For iCnt = 1 To iReq
iPos = InStr(sSt, sDelim)
If iPos Then
If iCnt = iReq Then ' 请求字符串
Parse = Left$(sSt, iPos - 1)
Exit For
End If
If iPos = Len(sSt) Then
Parse = ""
Exit For
End If
sSt = Mid$(sSt, iPos + Len(sDelim))
Else
Parse = sSt
Exit For
End If
Next iCnt
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?