两个字符串处理函数

时间:2009-07-10 04:43:55
【文件属性】:

文件名称:两个字符串处理函数

文件大小:4KB

文件格式:RAR

更新时间:2009-07-10 04:43:55

其它类别 函数 字符串处理函数 源码 源码下载

发布2个字符串处理函数: 1、ParameterValue() 2、ParameterCount() 用法示例: dim TheString as String TheString="欢迎,光临,枕善居,源代码" msgbox ParameterCount(",",TheString) 返回 4 ParameterValue(",",TheString,2) 返回 "欢迎" Public Function ParameterCount(ParseCharacter As String, _ tString As Variant) As Integer Dim CurrentPosition As Integer Dim ParseToPosition As Integer Dim CurrentToken As Integer Dim TempString As String TempString = Trim(tString) + ParseCharacter If Len(TempString) = 1 Then Exit Function CurrentPosition = 1 CurrentToken = 1 Do ParseToPosition = InStr(CurrentPosition, TempString, _ ParseCharacter) CurrentToken = CurrentToken + 1 CurrentPosition = ParseToPosition + 1 Loop Until (CurrentPosition >= Len(TempString)) ParameterCount = CurrentToken - 1 End Function Public Function ParameterValue(ParseCharacter As String, _ tString As Variant, _ Index As Integer) As String Dim CurrentPosition As Integer Dim ParseToPosition As Integer Dim CurrentToken As Integer Dim TempString As String TempString = Trim(tString) + ParseCharacter If Len(TempString) = 1 Then Exit Function CurrentPosition = 1 CurrentToken = 1 Do ParseToPosition = InStr(CurrentPosition, TempString, _ ParseCharacter) If Index = CurrentToken Then ParameterValue = Mid$(TempString, CurrentPosition, _ ParseToPosition - CurrentPosition) Exit Function End If CurrentToken = CurrentToken + 1 CurrentPosition = ParseToPosition + 1 Loop Until (CurrentPosition >= Len(TempString)) End Function


【文件预览】:
新建 文本文档.txt

网友评论