|
|
 | | From: | =?Utf-8?B?5Y+y5pmU5L+K?= | | Subject: | =?Utf-8?B?5aaC5L2V5oyJ5a2X6IqC5pWw5Y+W5a2X56ym?= | | Date: | Thu, 30 Dec 2004 22:47:01 -0800 |
|
|
 | 在VB.NET中如何按字节数取一定数量的字符,网上一些方法对VB6有效,在VB.NET中无效,不知有否实现方法,盼高手解答.
|
|
 | | From: | chanmmn | | Subject: | Re: ????????? | | Date: | Mon, 3 Jan 2005 22:44:09 +0800 |
|
|
 | Show me the page for VB6 then I can help you in VB.NET.
chanmm
"???" <@discussions.microsoft.com> wrote in message news:3F092BCB-0788-4D94-872E-065F04EA9A7F@microsoft.com... > ?VB.NET???????????????,???????VB6??,?VB.NET???,????????,?????.
|
|
 | | From: | =?Utf-8?B?5Y+y5pmU5L+K?= | | Subject: | =?Utf-8?B?VkI25Luj56CB5aaC5LiL77ya?= | | Date: | Mon, 3 Jan 2005 17:03:02 -0800 |
|
|
 | 1.UniCode转成ByteAry Dim byteAry() As Byte Dim str5 As String Dim i As Long str5 = "这abc" byteAry = str5 For i = LBound(byteAry) To UBound(byteAry) Debug.Print byteAry(i) '得 25 144 97 0 98 0 99 0 Next i Debug.Print Len(str5), LenB(str5) '得4 8
所以了,可看出UniCode 的特性,程式应改一下,使用Strconv()来转换 Dim byteAry() As Byte Dim str5 As String Dim i As Long str5 = "这abc" byteAry = StrConv(str5, vbFromUnicode) For i = LBound(byteAry) To UBound(byteAry) Debug.Print byteAry(i) 'VB6中得 25 144 97 98 99 在VB.NET中结果同上因此无法直接取字节 Next i Debug.Print LenB(StrConv(str5, vbFromUnicode)) '得5
2.ByteAry转回UniCode 使用Strconv()转换 Dim byteAry(10) as Byte Dim Str5 as String byteAry(0) = 25 byteAry(1) = 144 byteAry(2) = 97 byteAry(3) = 98 byteAry(4) = 99 Str5 = StrConv(byteAry, vbUniCode)
麻烦各位高手看看。
|
|
 | | From: | clark zhu | | Subject: | =?UTF-8?B?UmU6IFZCNuS7o+eggeWmguS4i++8mg==?= | | Date: | Tue, 4 Jan 2005 14:16:17 +0800 |
|
|
 | Dim a As String = "这abc" Dim b() As Byte Dim c As String
Dim en As System.Text.Encoding en = System.Text.Encoding.GetEncoding(936) b = en.GetBytes(a) c = en.GetString(b)
这样可以吗
"史晔俊" <@discussions.microsoft.com> wrote in message news:EC9A7242-33F0-4A7B-BBA5-EF034FAD08F1@microsoft.com... > 1.UniCode转成ByteAry > Dim byteAry() As Byte > Dim str5 As String > Dim i As Long str5 = "这abc" > byteAry = str5 > For i = LBound(byteAry) To UBound(byteAry) > Debug.Print byteAry(i) '得 25 144 97 0 98 0 99 0 > Next i > Debug.Print Len(str5), LenB(str5) '得4 8 > > 所以了,可看出UniCode 的特性,程式应改一下,使用Strconv()来转换 > Dim byteAry() As Byte > Dim str5 As String > Dim i As Long > str5 = "这abc" > byteAry = StrConv(str5, vbFromUnicode) > For i = LBound(byteAry) To UBound(byteAry) > Debug.Print byteAry(i) 'VB6中得 25 144 97 98 99 在VB.NET中结果同上因此无法 直接取字节 > Next i > Debug.Print LenB(StrConv(str5, vbFromUnicode)) '得5 > > 2.ByteAry转回UniCode 使用Strconv()转换 > Dim byteAry(10) as Byte > Dim Str5 as String > byteAry(0) = 25 > byteAry(1) = 144 > byteAry(2) = 97 > byteAry(3) = 98 > byteAry(4) = 99 > Str5 = StrConv(byteAry, vbUniCode) > > 麻烦各位高手看看。
|
|
|