vb 如何將byte陣列轉換成字串(相容中英文)

時間 2021-12-23 01:00:27

1樓:匿名使用者

要看什麼**,如果byte陣列資料本身是vb生成的,辦法較簡單。

dim s as string

s = "中華人民共和國republic of china"

dim b() as byte

b = s' 直接賦值位元組陣列,每個字元都佔兩個位元組debug.print ubound(b)debug.print cstr(b) '陣列轉換字串也簡單b = strconv(s, vbfromunicode) '先轉換為緊湊字串賦給陣列(英文本母只佔乙個位元組)

debug.print ubound(b)debug.print strconv(b, vbunicode) '陣列轉換為雙位元組字串

2樓:匿名使用者

private function bytes2gb(b() as byte) as string

dim i as integer

dim by as long

'判斷中英文

for i = 0 to ubound(b)by = b(i)

if b(i) >= 128 then

by = 256 * by + b(i + 1) - 65536i = i + 1

end if

bytes2gb = bytes2gb + chr(by)next

end function

vb 如何將乙個二進位制陣列中的資料轉化為字串

3樓:匿名使用者

答案補充:中文啊,呵呵,好說,chr改為chrw就行了。

建乙個command1。

**如下。

============

dim bytesdata

private sub command1_click()dim i as integer, s as stringbytesdata = array(8, 0, 48, 49, 50, 51, 52, 53, 54, 55)

for i = lbound(bytesdata) to ubound(bytesdata)

s = s & chrw(bytesdata(i))next

print s

end sub

4樓:匿名使用者

可以直接用函式實現;

參考例項如下:

function bytes2bstr(vin)strreturn = ""

for i = 1 to lenb(vin)thischarcode = ascb(midb(vin,i,1))if thischarcode <

else

nextcharcode = ascb(midb(vin,i+1,1))

i = i + 1

end if

next

bytes2bstr = strreturnend function

5樓:匿名使用者

注意位元組值不能為0,適合單位元組字元或雙位元組漢字:

private sub command1_click()dim stemp as string

ytemp(2) = &h1

ytemp(3) = &h48

ytemp(4) = &h49

ytemp(5) = &h50

ytemp(6) = &h51

ytemp(7) = &h52

ytemp(8) = &h53

ytemp(9) = &h54

ytemp(10) = &h55

stemp = strconv(ytemp, vbunicode)text1 = stemp

end sub

c中如何將Point陣列轉換為listPoint

1,從system.string轉到list system.string str listlists new list str 2,從list轉到system.string listlists new list lists.add str lists.add hello system.string ...

vb程式設計中如何將abcd轉換為abcd

private sub form click dim char as variant,i as byte,mystr as string char split a,b,c,d for i 0 to ubound char mystr mystr char i vbcrlfnext end sub 請...

如何將轉換成pdf,如何將word文件轉換成pdf

如何將word轉換成pdf?接下來教大家簡單的轉換方法 excel或word轉換pdf有多種方法,介紹兩種 1 2007以上版本的excel或word,有乙個輸入pdf功能。可以直接轉為pdf 2 安裝乙個pdf虛擬印表機,網上很多比如pdffactory pro dopdf等很多,然後在word或...

如何將轉換為,如何將Powerpoint文件轉換為Word文件

1 首先開啟需要轉換成中文word檔案的中文powerpoint檔案,然後滑鼠左鍵依次選擇 檔案 傳送 microsoft word 命令項。2.完成選擇之後,系統首先會出現 撰寫 對話方塊,此時應當在 在microsoft word使用的版式 欄中選擇一種版面的配置,然後在 將幻燈片新增到micr...

在vb中如何將數字轉換成字元型別

cstr 1.25 他們說的和正確,但是有個缺點。轉換的時候,cstr會把數字的正負表示出來。1.25是正數,應該轉換成 1.25 但由於vb對正號的省略則轉換成 1.25 那麼你就會發現,有的時候cint cstr 1.25 會出現型別錯誤。因此得想辦法把轉換過程中產生的空格去掉。replace ...