会的人不会看,不会的看不懂。
非常经典!~
Now is future !~
模拟vb.net string类:
Private Text_ As String
Public Enum Str_Conv '字格式转换常数
FirstByteToUpper = 3 '3 第一个英文字大写
HalfToAll = 4 '4 所有半型字转全型字
AllToHalf = 8 '8 所有全型字转半型字
SingleCodeToUnicode = 64 '64 所有Single Code字转成UniCode字
UniCodeToSingleCode = 128 '128 所有UniCode字转成Single Code字
End Enum
Property Get Text() As String
Text = Text_
End Property
Property Let Text(ByVal NewText As String)
Text_ = NewText
End Property
Public Function GetLeft(ByVal LeftIndex As Integer) As String '截取字串左边某几个字符
GetLeft = Left(Text_, LeftIndex)
End Function
Public Function GetRight(ByVal RightIndex As Integer) As String '截取字串右边某几个字符
GetRight = Right(Text_, RightIndex)
End Function
Public Function GetMid(ByVal MidIndex As Integer, ByVal LenIndex As Integer) As String '截取字串右边某几个字符
GetMid = Mid(Text_, MidIndex, LenIndex)
End Function
Public Function ToLower() As String '字符串全转小写
ToLower = LCase(Text_)
End Function
Public Function ToUpper() As String '字符串全转大写
ToUpper = UCase(Text_)
End Function
Public Function SetStrConv(ByVal TextConv As Str_Conv) As String '字格式转换
SetStrConv = StrConv(Text_, TextConv)
End Function
Public Function InStrIndex(ByVal SubText As String) As Integer '传回字串里某个字串在第几个字的位置
InStrIndex = InStr(Text_, SubText)
End Function
Public Function InStrBIndex(ByVal SubBText As String) As Integer '传回字串里某个字串在第几个字符的位置
InStrBIndex = InStrB(Text_, SubBText)
End Function
Public Function GetLen() As Integer '传回字串有多少字数
GetLen = Len(Text_)
End Function
Public Function GetLenB() As Integer '传回字串有多少字符
GetLenB = LenB(Text_)
End Function
Public Function InStrRevIndex(ByVal InstrRevText As String, ByVal StartFindIndex As Integer) As String 'InStrRev是从起始位置开始倒着找
InStrRevIndex = InStrRev(InstrRevText, StartFindIndex)
End Function
Public Function ToLTrim() As String '删除字串左边的空白字串
ToLTrim = LTrim(Text_)
End Function
Public Function ToRTrim() As String 'RTrim 删除字串右边的空白字串
ToRTrim = RTrim(Text_)
End Function
Public Function ToTrim() As String 'Trim 删除字串首尾的空白字串
ToTrim = Trim(Text_)
End Function
Public Function SetReplace(ByVal WillFindString As String, ByVal WillReplaceString As String, ByVal StartIndex As Integer, ByVal GroundIndex As Integer) As String
SetReplace = Replace(Text_, WillFindString, WillReplaceString, StartIndex, GroundIndex)
End Function '取代自串中某些字符串
Public Function LetStrReverse() As String '反转字符串
LetStrReverse = StrReverse(Text_)
End Function