Program VB Net Konversi Bilangan

Ternyata program vb net konversi bilangan ke hexa, octal dan biner tidak terlalu sulit.

Design form program vb net konversi bilangan seperti pada gambar cover tersebut. Pada program terdapat 2 Textbox dengan nama BilInput dan BilOutput, serta memiliki 3 Button dengan nama btnOctal, btnBinner, btnHexa.

Berikut listing program vb net konversi bilangan
Public Class frmKonversi

    Private Sub btnHexa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHexa.Click
        BilOutput.Text = Hex(Val(BilInput.Text))
    End Sub

    Private Sub btnBinner_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBinner.Click
        Dim xHexa As String = Hex(Val(BilInput.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

        BilOutput.Text = xbin2
    End Sub

    Private Sub btnOctal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOctal.Click
        BilOutput.Text = Oct(Val(BilInput.Text))
    End Sub

End Class


Sumber : Mesran.net
Back to top