STRING.BAS
上传用户:hyb6888
上传日期:2016-01-24
资源大小:5186k
文件大小:1k
- Attribute VB_Name = "STRING"
- '截分失败则返回为空
- Function MyCutStr(CutString As String, CutChar As String) As String
- '用给定的字符串把字符串切成两半,并半部返回,后半部放入第一个参数中
- Dim mypos As Integer
- mypos = InStr(1, CutString, CutChar, 1)
- If mypos <> 0 Then
- MyCutStr = Left(CutString, mypos - 1)
- CutString = Right(CutString, Len(CutString) - mypos)
- End If
- End Function
- '得到指定位置的一个字符
- Function mygetchar(ss As String, i As Integer) As String
- Dim st As String
- st = Chr(Asc(Right(ss, Len(ss) - i + 1)))
- mygetchar = st
- End Function
- Sub sdfljasdf()
- MsgBox mylen("a中d中ll")
- End Sub
- Function mylen(ss As String) As Integer
- Dim lon As Integer
- Dim s1 As String
- Dim i As Integer, t As Integer
- i = 1
- t = 0
- lon = Len(ss)
- While i <= lon
- s1 = mygetchar(ss, i)
- If Asc(s1) < 0 Or Asc(s1) > 257 Then
- t = t + 2
- Else
- t = t + 1
- End If
- i = i + 1
- Wend
- mylen = t
- End Function