相关的知识总结一哈~~~
使用Convert类的ToInt32()fang方法把二,八,十六进制数转换为十进制,
Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mydim1 As Integer
Dim mydim2 As Integer
Dim mydim3 As Integer
Dim mybinary As String = "1111"
Dim myoctal As String = "17"
Dim myhex As String = "f"
mydim1 = Convert.ToInt32(mybinary, 2).ToString()
mydim2 = Convert.ToInt32(myoctal, 8).ToString()
mydim3 = Convert.ToInt32(myhex, 16).ToString()
Label1.Text = "MyBinary=1111转换为十进制:" & mydim1
Label2.Text = "MyOctal=17转换为十进制:" & mydim2
Label3.Text = "Myhex=f转换为十进制:" & mydim3
End Sub
可以使用Convert类的ToString()方法把十进制转换为二,八,十六进制数;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mydim As Integer = 15
Dim mybinary As String
Dim myoctal As String
Dim myhex As String
mybinary = Convert.ToString(mydim, 2).ToString()
myoctal = Convert.ToString(mydim, 8).ToString()
myhex = Convert.ToString(mydim, 16).ToString()
Label1.Text = "十进制15转换为二进制:MyBinary=" & mybinary
Label2.Text = "十进制15转换为八进制:MyOctal=" & myoctal
Label3.Text = "十进制15转换为十六进制:Myhex=" & myhex
End Sub