Cara Membuat Program Konversi Bilangan di VB NET




Ass, Selamat sore sobat disini saya akan memberi koding tentang caara mengkonversi bilangan sesuai apa yg akan di lakukan, langsung saja berikut ketikan perintah-perintah di bawah ini:



Public Class Form1

    Private Sub BtnHexa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHexa.Click
        output.Text = Hex(Val(input.Text))

    End Sub

    Private Sub BtnOktal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOktal.Click
        output.Text = Oct(Val(input.Text))

    End Sub

    Private Sub BtnBiner_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBiner.Click
        Dim xHexa As String = Hex(Val(input.Text))
        Dim xBin As String
        Dim xbin2 As String
        Dim xKata As String
        Dim i As Integer
        xbin2 = ""
        For i = 1 To Len(xHexa)
            xBin = ""
            xKata = Mid(xHexa, i, 1)
            Select Case UCase(xKata)
                Case "0" : xBin = "0000"
                Case "1" : xBin = "0001"
                Case "2" : xBin = "0010"
                Case "3" : xBin = "0011"
                Case "4" : xBin = "0100"
                Case "5" : xBin = "0101"
                Case "6" : xBin = "0110"
                Case "7" : xBin = "0111"
                Case "8" : xBin = "1000"
                Case "9" : xBin = "1001"
                Case "A" : xBin = "1010"
                Case "B" : xBin = "1011"
                Case "C" : xBin = "1100"
                Case "D" : xBin = "1101"
                Case "E" : xBin = "1110"
                Case "F" : xBin = "1111"
                Case "h", "H" : xBin = ""
                Case Else : xBin = ""

            End Select

            xbin2 = xbin2 + xBin
        Next i
        output.Text = xbin2
    End Sub

    Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
        Me.Close()
    End Sub

    Private Sub BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHapus.Click
        input.Text = ""
        output.Text = ""
    End Sub
End Class




Previous
Next Post »