类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
比如字串:"12345abcdefg", 要得到"12345abcde"
"12345中文字串", 则要得到"12345中文" (最后半个中文字舍弃)
如果没有相应的函数,要自己写循环遍历的代码,那就算了,我自己能写出来。
谢谢关注。
网友回答:
leftb(string,length)
length是字节数
"12345abcdefg", 要得到"12345abcde"
leftb("12345abcdefg",20)
"12345中文字串", 则要得到"12345中文"
leftb("12345中文字串",14)
MsgBox StrConv(LeftB(StrConv("12345中文字串", vbFromUnicode), 10), vbUnicode)
一个转换的例子:
Private Sub Command3_Click()
Dim a As String
Dim b() As Byte
Dim c() As Byte
Dim s$
a = "12上海12"
b = StrConv(a, vbFromUnicode)
For i = 0 To UBound(b)
Debug.Print b(i);
Next i
ReDim c(3) As Byte
For i = 0 To 3
c(i) = b(i)
Next i
s = StrConv(c, vbUnicode)
Debug.Print s; 取得“12上”
ReDim c(5) As Byte
For i = 0 To 5
c(i) = b(i)
Next i
s = StrConv(c, vbUnicode)
Debug.Print s; 取得“12上海”
End Sub