vb定義字符串?dāng)?shù)組 VB字符串和字節(jié)數(shù)組的轉(zhuǎn)換?
VB字符串和字節(jié)數(shù)組的轉(zhuǎn)換?Dimsasstring,a()asbyte,s1asstrings=“123456abcdef”a=strconv(s,vbfromunicode)“string to
VB字符串和字節(jié)數(shù)組的轉(zhuǎn)換?
Dimsasstring,a()asbyte,s1asstrings=“123456abcdef”a=strconv(s,vbfromunicode)“string to byte array S1=strconv(a,vbunicode)”byte array to string msgboxs1
VB string在轉(zhuǎn)換到系統(tǒng)的默認(rèn)代碼頁(yè)后,可以使用strconv函數(shù)從Unicode轉(zhuǎn)換為系統(tǒng)的十六進(jìn)制字符每個(gè)字節(jié)都被獲取并拼接在一起。strconv函數(shù)返回由指定類(lèi)型轉(zhuǎn)換的變量(字符串)。實(shí)現(xiàn)代碼:private sub command1uclick()dim strsj as StringDim strhexsj as StringDim I as longdim bytsj()as bytestrsj=“123abc hex”bytsj=strconv(strsj,vbfromunicode)for I=0 to UBound(bytsj)strhexsj=strhexsj&;right(“0”&hex(bytsj(I)),2)下一個(gè)debug.PrintStrhexsjend sub
作為字符串的dim s=“123456”“get array Dim b as byte()=編碼.ASCII.GetBytes(s) “為B中的每個(gè)V顯示dim V as Byt調(diào)試.打?。╲) 下一步
~]“獲取數(shù)組
將b變?yōu)樽止?jié)()=編碼.ASCII.GetBytes(s)
顯示
將V變?yōu)樽止?jié)
對(duì)于B中的每個(gè)V調(diào)試.打印(v)
下一個(gè)