vb.net的hex的簡(jiǎn)單介紹

VB.NET中怎么將16進(jìn)制數(shù)換成對(duì)應(yīng)的ASCII,比如說(shuō)&H1000,怎么把他換成31H,30H,30H,30H

Public Function dec_to_hex(dec As Long) As String

創(chuàng)新互聯(lián)公司主營(yíng)榕江網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app軟件定制開發(fā),榕江h(huán)5微信小程序開發(fā)搭建,榕江網(wǎng)站營(yíng)銷推廣歡迎榕江等地區(qū)企業(yè)咨詢

Dim a As String

dec_to_hex = ""

Do While dec 0

a = CStr(dec Mod 16)

Select Case a

Case "0": a = "30H"

Case "1": a = "31H"

Case "2": a = "32H"

Case "3": a = "33H"

Case "4": a = "34H"

Case "5": a = "35H"

Case "6": a = "36H"

Case "7": a = "37H"

Case "8": a = "38H"

Case "9": a = "30H"

Case "10": a = "65H"

Case "11": a = "66H"

Case "12": a = "67H"

Case "13": a = "68H"

Case "14": a = "69H"

Case "15": a = "70H"

End Select

dec_to_hex = a " " dec_to_hex

dec = dec \ 16

Loop

End Function

VB.NET,八/十六進(jìn)制轉(zhuǎn)十進(jìn)制的函數(shù),怎么轉(zhuǎn)?

'此函數(shù)用于十進(jìn)制到二進(jìn)制

Private Function Bin(Number As Long) As Long

Dim Div_value As String

Do

Div_value = (Number Mod 2) Div_value

Number = Int(Number / 2)

Loop Until Number 2

Bin = Number Div_value

End Function

'此函數(shù)用于二進(jìn)制到十進(jìn)制

Private Function value_Bin(Number As Long) As Long

Dim Temp_value As Long, Cyc As Long

For Cyc = 0 To Len(Str(Number))

If Cyc = Len(Str(Number)) Then

value_Bin = Temp_value + Val(Mid(Str(Number), Cyc, 1))

Exit For

End If

If Cyc 0 Then Temp_value = (Temp_value + Val(Mid(Str(Number), Cyc, 1))) * 2

Next Cyc

End Function

'====寫入以上函數(shù)后轉(zhuǎn)值操作:

'十進(jìn)制到十六進(jìn)制:Hex(十進(jìn)制數(shù)值)

'十進(jìn)制到八進(jìn)制:Oct(十進(jìn)制數(shù)值)

'十進(jìn)制到二進(jìn)制:Bin(十進(jìn)制數(shù)值)

'二進(jìn)制到十進(jìn)制:value_Bin(二進(jìn)制數(shù)值)

'八進(jìn)制到十進(jìn)制:Val("O" 八進(jìn)制數(shù)值)

'十六進(jìn)制到十進(jìn)制:Val("H" 十六進(jìn)制數(shù)值)

比如

msgbox DEC_to_BIN(10)

就會(huì)返回一個(gè)10轉(zhuǎn)換為十進(jìn)制后的結(jié)果

或者簡(jiǎn)單點(diǎn)就用

VB自帶函數(shù):

十進(jìn)制轉(zhuǎn)八進(jìn)制:Oct(num)

十六進(jìn)制轉(zhuǎn)八進(jìn)制:oct("H" num)

十進(jìn)制轉(zhuǎn)十六進(jìn)制:hex(num)

八進(jìn)制轉(zhuǎn)十六進(jìn)制:hex("O" num)

十六進(jìn)制轉(zhuǎn)換為十進(jìn)制

Dim str As String

str = Text2.Text

Text10.Text = CLng("H" str)

vb.net 把十進(jìn)制數(shù)轉(zhuǎn)成十六進(jìn)制數(shù)的函數(shù)有哪些?

Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load

MsgBox(DEC_to_HEX(255))

End?Sub

Public?Function?DEC_to_HEX(ByVal?Dec?As?Long)?As?String

Dim?a?As?String

DEC_to_HEX?=?""

Do?While?Dec??0

a?=?CStr(Dec?Mod?16)

Select?Case?a

Case?"10"?:?a?=?"A"

Case?"11"?:?a?=?"B"

Case?"12"?:?a?=?"C"

Case?"13"?:?a?=?"D"

Case?"14"?:?a?=?"E"

Case?"15"?:?a?=?"F"

End?Select

DEC_to_HEX?=?a??DEC_to_HEX

Dec?=?Dec?\?16

Loop

End?Function

名稱欄目:vb.net的hex的簡(jiǎn)單介紹
當(dāng)前地址:http://muchs.cn/article8/dojhjip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站營(yíng)銷、靜態(tài)網(wǎng)站、響應(yīng)式網(wǎng)站、品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)