10進制轉16進制的話可以使用HEX()函數(shù),16進制轉10進制沒有現(xiàn)成函數(shù),可以使用如下代碼實現(xiàn):
站在用戶的角度思考問題,與客戶深入溝通,找到瀘溪網(wǎng)站設計與瀘溪網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設計與互聯(lián)網(wǎng)技術結合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站制作、成都網(wǎng)站建設、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、域名申請、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務覆蓋瀘溪地區(qū)。
'?用途:將十六進制轉化為十進制
'?輸入:Hex(十六進制數(shù))
'?輸入數(shù)據(jù)類型:String
'?輸出:HEX_to_DEC(十進制數(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
擴展資料:
在VB中將十進制轉化為十六進制的函數(shù):
輸入:Dec(十進制數(shù))'
輸入數(shù)據(jù)類型:Long'
輸出:D2H(十六進制數(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、運行“Microsoft Visual Studio 2010”。
2、”vs“的窗口彈出后,找到菜單欄,鼠標左鍵單擊標題為”文件(f)“的選項。
3、在彈出的列表中鼠標左鍵單擊標題為”新建項目(p)“的項。
4、在彈出的標題為”新建項目“,鼠標左鍵選擇標題為”Visual Basic“項,在選擇標題為”WIndows“的項。再在右邊的列表中選擇標題為”Windows 窗體應用程序“。
5、在一個背景為”白色"的窗口,且標題為“ForM1”的窗口中的空白處鼠標左鍵雙擊。
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 "選擇的進制與數(shù)不符": Exit Sub
If Jz = 0 Then Pic.Print "請先輸入進制" 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
文章題目:關于vb.net10轉16的信息
本文路徑:http://www.rwnh.cn/article28/dopppjp.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供面包屑導航、云服務器、動態(tài)網(wǎng)站、網(wǎng)站營銷、靜態(tài)網(wǎng)站、
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)