vb字串和位元組陣列轉換奇怪的問題解決

2021-04-29 19:56:41 字數 1222 閱讀 6971

問題
private sub form_load()

dim b() as byte

dim s as string

s = "aaa;ss;111;中國"

debug.print s

b = strconv(s, vbfromunicode) ' 字串轉成陣列

s = strconv(b, vbtounicode) ' 陣列轉成字串

debug.print s

end sub

aaa;ss;111;中國

慡?獳????ú 這裡為什麼轉換不會來了?怎麼才能讓他回來呢?

在csdn有與lz相同的問貼,已有網友指出下句錯 

s = strconv(b, vbtounicode) ' 陣列轉成字串

應該為:

s = strconv(b, vbunicode) ' 陣列轉成字串

參閱nsdn:

strconv 函式

返回按指定型別轉換的 variant (string)。

語法 strconv(string, conversion, lcid)

strconv 函式的語法有下面的命名引數:

部分 說明

string 必要引數。要轉換的字串表示式。

conversion 必要引數。integer。其值的和決定轉換的型別。

lcid 可選的。如果與系統localeid不同,則為localeid(系統localeid為預設值。)

設定值

conversion 引數的設定值為:

常數 值 說明

vbuppercase 1 將字串文字轉成大寫。

vblowercase 2 將字串文字轉成小寫。

vbpropercase 3 將字串中每個字的開頭字母轉成大寫。

vbwide* 4* 將字串中單位元組字元轉成雙位元組字元。

vbnarrow* 8* 將字串中雙位元組字元轉成單位元組字元。

vbkatakana** 16** 將字串中平假名字元轉成片假名字元。

vbhiragana** 32** 將字串中片假名字元轉成平假名字元。

vbunicode 64 根據系統的預設碼頁將字串轉成 unicode。

vbfromunicode 128 將字串由 unicode 轉成系統的預設碼頁。

C 字串和位元組陣列轉換

定義string變數為str,記憶體流變數為ms,位元陣列為bt 1.字串轉位元陣列 1 byte bt system.text.encoding.default.getbytes 字串 2 byte bt convert.frombase64string 字串 2.字串轉流 1 memorystr...

字串與位元組陣列的轉換

字串與位元組陣列的轉換 string str helloworld byte data str.getbytes for int x 0 x data.length x data x 32 system.out.print datd x system.out.println new string d...

字串 位元組陣列 字元陣列之間的轉換

package stringexample 1.字串與基本資料型別 包裝類之間的轉換 字串 基本資料型別 包裝類 呼叫相應的包裝類的pa xx string str 基本資料型別 包裝類 字串 字串過載的valueof 方法 2.字串與位元組陣列 字串 位元組陣列 字串的getbytes 位元組陣列...