10進(jìn)制轉(zhuǎn)16進(jìn)制的話可以使用HEX()函數(shù),16進(jìn)制轉(zhuǎn)10進(jìn)制沒有現(xiàn)成函數(shù),可以使用如下代碼實(shí)現(xiàn):
站在用戶的角度思考問題,與客戶深入溝通,找到瀘溪網(wǎng)站設(shè)計(jì)與瀘溪網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名申請(qǐng)、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋瀘溪地區(qū)。
'?用途:將十六進(jìn)制轉(zhuǎn)化為十進(jìn)制
'?輸入:Hex(十六進(jìn)制數(shù))
'?輸入數(shù)據(jù)類型:String
'?輸出:HEX_to_DEC(十進(jìn)制數(shù))
'?輸出數(shù)據(jù)類型:Long
'?輸入的最大數(shù)為7FFFFFFF,輸出的最大數(shù)為2147483647
Public?Function?HEX_to_DEC(ByVal?Hex?As?String)?As?Long
Dim?i?As?Long
Dim?B?As?Long
Hex?=?UCase(Hex)
For?i?=?1?To?Len(Hex)
Select?Case?Mid(Hex,?Len(Hex)?-?i?+?1,?1)
Case?"0":?B?=?B?+?16?^?(i?-?1)?*?0
Case?"1":?B?=?B?+?16?^?(i?-?1)?*?1
Case?"2":?B?=?B?+?16?^?(i?-?1)?*?2
Case?"3":?B?=?B?+?16?^?(i?-?1)?*?3
Case?"4":?B?=?B?+?16?^?(i?-?1)?*?4
Case?"5":?B?=?B?+?16?^?(i?-?1)?*?5
Case?"6":?B?=?B?+?16?^?(i?-?1)?*?6
Case?"7":?B?=?B?+?16?^?(i?-?1)?*?7
Case?"8":?B?=?B?+?16?^?(i?-?1)?*?8
Case?"9":?B?=?B?+?16?^?(i?-?1)?*?9
Case?"A":?B?=?B?+?16?^?(i?-?1)?*?10
Case?"B":?B?=?B?+?16?^?(i?-?1)?*?11
Case?"C":?B?=?B?+?16?^?(i?-?1)?*?12
Case?"D":?B?=?B?+?16?^?(i?-?1)?*?13
Case?"E":?B?=?B?+?16?^?(i?-?1)?*?14
Case?"F":?B?=?B?+?16?^?(i?-?1)?*?15
End?Select
Next?i
HEX_to_DEC?=?B
End?Function
擴(kuò)展資料:
在VB中將十進(jìn)制轉(zhuǎn)化為十六進(jìn)制的函數(shù):
輸入:Dec(十進(jìn)制數(shù))'
輸入數(shù)據(jù)類型:Long'
輸出:D2H(十六進(jìn)制數(shù))'
輸出數(shù)據(jù)類型:String'
輸入的最大數(shù)為2147483647,
輸出最大數(shù)為7FFFFFFFPublicFunction D2H(Dec As Long) As String
Dim a As String
D2H = ""
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
D2H = a D2H
Dec = Dec \ 16 ? ? LoopEnd Function
1、運(yùn)行“Microsoft Visual Studio 2010”。
2、”vs“的窗口彈出后,找到菜單欄,鼠標(biāo)左鍵單擊標(biāo)題為”文件(f)“的選項(xiàng)。
3、在彈出的列表中鼠標(biāo)左鍵單擊標(biāo)題為”新建項(xiàng)目(p)“的項(xiàng)。
4、在彈出的標(biāo)題為”新建項(xiàng)目“,鼠標(biāo)左鍵選擇標(biāo)題為”Visual Basic“項(xiàng),在選擇標(biāo)題為”WIndows“的項(xiàng)。再在右邊的列表中選擇標(biāo)題為”Windows 窗體應(yīng)用程序“。
5、在一個(gè)背景為”白色"的窗口,且標(biāo)題為“ForM1”的窗口中的空白處鼠標(biāo)左鍵雙擊。
6、在新切換到的“代碼編輯頁面”。
7、再在 “Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load”下寫代碼。就可以了。
Option Explicit
Dim Jz As Integer, K As Boolean
Private Sub Command1_Click()
Pic.Cls
If K Then Jz = Val(Qtjz.Text)
If Pd(Text1.Text, Jz) Then Pic.Print "選擇的進(jìn)制與數(shù)不符": Exit Sub
If Jz = 0 Then Pic.Print "請(qǐng)先輸入進(jìn)制" Else Pic.Print Zh(Text1.Text, Jz)
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
Private Sub Option1_Click(Index As Integer)
K = False
Select Case Index
Case 0
Jz = 2
Case 1
Jz = 8
Case 2
Jz = 10
Case 3
Jz = 16
Case 4
K = True
Qtjz.Text = ""
Qtjz.SetFocus
End Select
If Index 4 Then Command1.SetFocus
End Sub
Private Sub Qtjz_Click()
Qtjz.Text = ""
End Sub
Private Sub Text1_Click()
Text1.Text = ""
End Sub
Private Function Zh(a As String, b As Integer) As Integer
Dim c As String, i, d As Integer
a = LCase(a)
For i = 1 To Len(a)
c = Mid(a, Len(a) + 1 - i, 1)
If Asc(c) 96 Then d = Asc(c) - 87 Else d = Val(c)
Zh = Zh + d * b ^ (i - 1)
Next i
End Function
Private Function Pd(a As String, b As Integer) As Boolean
Dim c As String, i, d As Integer
Pd = False
For i = 1 To Len(a)
c = Mid(a, Len(a) + 1 - i, 1)
If Asc(c) 96 Then d = Asc(c) - 87 Else d = Val(c)
If d b - 1 Then Pd = True: Exit Function
Next i
End Function
文章題目:關(guān)于vb.net10轉(zhuǎn)16的信息
本文路徑:http://jinyejixie.com/article28/dopppjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、云服務(wù)器、動(dòng)態(tài)網(wǎng)站、網(wǎng)站營銷、靜態(tài)網(wǎng)站、
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)