Rabu, 08 Juni 2016

Membuat Aplikasi Pembayaran dengan Visual Basic

Hai! Kali ini saya akan menunjukkan bagaimana membuat Aplikasi Pembayaran pada sebuah warung makan

Step 1 : Buatlah design form sesuai yang anda inginkan atau bisa membuat form seperti contoh ini dan jangan lupa untuk membuat file Excel CSV




ComboBox1 = Nama Kasir
DateTimePicker1 = menampilkan pilihan tanggal
ComboBox2 hingga ComboBox6 = Jenis pesanan makanan
TextBox1 hingga TextBox5 = Jumlah pesanan makanan
TextBox6 hingga TextBox10 = Harga pesanan makanan
TextBox11 = Total harga makanan
ComboBox7 hingga ComboBox11 = Jenis pesanan minuman
TextBox12 hingga TextBox16 = Jumlah pesanan minuman
TextBox17 hingga TextBox21 = Harga pesanan minuman
TextBox22 = Total harga minuman
TextBox23 = Total harga makanan dan minuman
TextBox24 = Bayar, jumlah uang yang di berikan customer
TextBox25 = Kembali, jumlah uang yang di berikan customer di kurang total harga makanan dan minuman
BtnTotal = Total harga makanan dan minuman
BtnHitung = menghasilkan TextBox25
BtnHapus = menghapus semua data
BtnSimpan = menyimpan data di excel dan akan muncul di ListBox1

Step 2 : Berikut Source Code dari aplikasi ini

Public Class Form1

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If ComboBox2.Text = "Nasi Goreng" Then
            TextBox6.Text = Val(TextBox1.Text) * 20000
        ElseIf ComboBox2.Text = "Bakso" Then
            TextBox6.Text = Val(TextBox1.Text) * 10000
        ElseIf ComboBox2.Text = "Mie Ayam Bakso" Then
            TextBox6.Text = Val(TextBox1.Text) * 15000
        ElseIf ComboBox2.Text = "Kwetiau" Then
            TextBox6.Text = Val(TextBox1.Text) * 12000
        Else
            TextBox6.Text = Val(TextBox1.Text) * 7000
        End If
    End Sub

    Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
        If ComboBox3.Text = "Nasi Goreng" Then
            TextBox7.Text = Val(TextBox2.Text) * 20000
        ElseIf ComboBox3.Text = "Bakso" Then
            TextBox7.Text = Val(TextBox2.Text) * 10000
        ElseIf ComboBox3.Text = "Mie Ayam Bakso" Then
            TextBox7.Text = Val(TextBox2.Text) * 15000
        ElseIf ComboBox3.Text = "Kwetiau" Then
            TextBox7.Text = Val(TextBox2.Text) * 12000
        Else
            TextBox7.Text = Val(TextBox2.Text) * 7000
        End If
    End Sub

    Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
        If ComboBox4.Text = "Nasi Goreng" Then
            TextBox8.Text = Val(TextBox3.Text) * 20000
        ElseIf ComboBox4.Text = "Bakso" Then
            TextBox8.Text = Val(TextBox3.Text) * 10000
        ElseIf ComboBox4.Text = "Mie Ayam Bakso" Then
            TextBox8.Text = Val(TextBox3.Text) * 15000
        ElseIf ComboBox4.Text = "Kwetiau" Then
            TextBox8.Text = Val(TextBox3.Text) * 12000
        Else
            TextBox8.Text = Val(TextBox3.Text) * 7000
        End If
    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
        If ComboBox5.Text = "Nasi Goreng" Then
            TextBox9.Text = Val(TextBox4.Text) * 20000
        ElseIf ComboBox5.Text = "Bakso" Then
            TextBox9.Text = Val(TextBox4.Text * 10000
        ElseIf ComboBox5.Text = "Mie Ayam Bakso" Then
            TextBox9.Text = Val(TextBox4.Text * 15000
        ElseIf ComboBox5.Text = "Kwetiau" Then
            TextBox9.Text = Val(TextBox4.Text * 12000
        Else
            TextBox9.Text = Val(TextBox4.Text * 7000
        End If
    End Sub

    Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles TextBox5.TextChanged
        If ComboBox6.Text = "Nasi Goreng" Then
            TextBox10.Text = Val(TextBox5.Text) * 20000
        ElseIf ComboBox6.Text = "Bakso" Then
            TextBox10.Text = Val(TextBox5.Text) * 10000
        ElseIf ComboBox6.Text = "Mie Ayam Bakso" Then
            TextBox10.Text = Val(TextBox5.Text) * 15000
        ElseIf ComboBox6.Text = "Kwetiau" Then
            TextBox10.Text = Val(TextBox5.Text) * 12000
        Else
            TextBox10.Text = Val(TextBox5.Text) * 7000
        End If
    End Sub

    Private Sub TextBox12_TextChanged(sender As Object, e As EventArgs) Handles TextBox12.TextChanged
        If ComboBox7.Text = "Teh Botol" Then
            TextBox17.Text = Val(TextBox12.Text) * 4000
        ElseIf ComboBox7.Text = "Es Jeruk" Then
            TextBox17.Text = Val(TextBox12.Text) * 4000
        ElseIf ComboBox7.Text = "Es Campur" Then
            TextBox17.Text = Val(TextBox12.Text) * 8000
        ElseIf ComboBox7.Text = "Fanta Susu" Then
            TextBox17.Text = Val(TextBox12.Text) * 5000
        Else
            TextBox17.Text = Val(TextBox12.Text) * 3000
        End If
    End Sub

    Private Sub TextBox13_TextChanged(sender As Object, e As EventArgs) Handles TextBox13.TextChanged
        If ComboBox8.Text = "Teh Botol" Then
            TextBox18.Text = Val(TextBox13.Text) * 4000
        ElseIf ComboBox8.Text = "Es Jeruk" Then
            TextBox18.Text = Val(TextBox13.Text) * 4000
        ElseIf ComboBox8.Text = "Es Campur" Then
            TextBox18.Text = Val(TextBox13.Text) * 8000
        ElseIf ComboBox8.Text = "Fanta Susu" Then
            TextBox18.Text = Val(TextBox13.Text) * 5000
        Else
            TextBox18.Text = Val(TextBox13.Text) * 3000
        End If
    End Sub

    Private Sub TextBox14_TextChanged(sender As Object, e As EventArgs) Handles TextBox14.TextChanged
        If ComboBox9.Text = "Teh Botol" Then
            TextBox19.Text = Val(TextBox14.Text) * 4000
        ElseIf ComboBox9.Text = "Es Jeruk" Then
            TextBox19.Text = Val(TextBox14.Text) * 4000
        ElseIf ComboBox9.Text = "Es Campur" Then
            TextBox19.Text = Val(TextBox14.Text) * 8000
        ElseIf ComboBox9.Text = "Fanta Susu" Then
            TextBox19.Text = Val(TextBox14.Text) * 5000
        Else
            TextBox17.Text = Val(TextBox12.Text) * 3000
        End If
    End Sub

    Private Sub TextBox15_TextChanged(sender As Object, e As EventArgs) Handles TextBox15.TextChanged
        If ComboBox10.Text = "Teh Botol" Then
            TextBox20.Text = Val(TextBox15.Text) * 4000
        ElseIf ComboBox10.Text = "Es Jeruk" Then
            TextBox20.Text = Val(TextBox15.Text) * 4000
        ElseIf ComboBox10.Text = "Es Campur" Then
            TextBox20.Text = Val(TextBox15.Text) * 8000
        ElseIf ComboBox10.Text = "Fanta Susu" Then
            TextBox20.Text = Val(TextBox15.Text) * 5000
        Else
            TextBox20.Text = Val(TextBox15.Text) * 3000
        End If
    End Sub

    Private Sub TextBox16_TextChanged(sender As Object, e As EventArgs) Handles TextBox16.TextChanged
        If ComboBox11.Text = "Teh Botol" Then
            TextBox21.Text = Val(TextBox16.Text) * 4000
        ElseIf ComboBox11.Text = "Es Jeruk" Then
            TextBox21.Text = Val(TextBox16.Text) * 4000
        ElseIf ComboBox11.Text = "Es Campur" Then
            TextBox21.Text = Val(TextBox16.Text) * 8000
        ElseIf ComboBox11.Text = "Fanta Susu" Then
            TextBox21.Text = Val(TextBox16.Text) * 5000
        Else
            TextBox21.Text = Val(TextBox16.Text) * 3000
        End If
    End Sub

    Private Sub BtnTotal_Click(sender As Object, e As EventArgs) Handles BtnTotal.Click
        TextBox11.Text = Val(TextBox6.Text) + Val(TextBox7.Text) + Val(TextBox8.Text) + Val(TextBox9.Text) + Val(TextBox10.Text)
        TextBox22.Text = Val(TextBox17.Text) + Val(TextBox18.Text) + Val(TextBox19.Text) + Val(TextBox20.Text) + Val(TextBox21.Text)
        TextBox23.Text = TextBox1.Text + TextBox22.Text
    End Sub

    Private Sub BtnHitung_Click(sender As Object, e As EventArgs) Handles BtnHitung.Click
        TextBox25.Text = TextBox24.Text - TextBox23.Text
    End Sub

    Private Sub BtnHapus_Click(sender As Object, e As EventArgs) Handles BtnHapus.Click
        ComboBox1.Text = ""
        ComboBox2.Text = ""
        ComboBox3.Text = ""
        ComboBox4.Text = ""
        ComboBox5.Text = ""
        ComboBox6.Text = ""
        ComboBox7.Text = ""
        ComboBox8.Text = ""
        ComboBox9.Text = ""
        ComboBox10.Text = ""
        ComboBox11.Text = ""
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        TextBox11.Text = ""
        TextBox12.Text = ""
        TextBox13.Text = ""
        TextBox14.Text = ""
        TextBox15.Text = ""
        TextBox16.Text = ""
        TextBox17.Text = ""
        TextBox18.Text = ""
        TextBox19.Text = ""
        TextBox20.Text = ""
        TextBox21.Text = ""
        TextBox22.Text = ""
        TextBox23.Text = ""
        TextBox24.Text = ""
        TextBox25.Text = ""
        ListBox1.Text = ""
    End Sub

    Private Sub BtnSimpan_Click(sender As Object, e As EventArgs) Handles BtnSimpan.Click
        Dim nofile As Integer
        Dim var1, var2, var3, var4, var5, var6, var7 As String
        nofile = FreeFile()
        FileOpen(nofile, "C:\Users\Velly\Desktop\Data Transaksi Pembayaran.CSV", OpenMode.Append)

        var1 = ComboBox1.Text
        var2 = DateTimePicker1.Text
        var3 = ComboBox2.Text & ComboBox3.Text & ComboBox4.Text & ComboBox5.Text & ComboBox6.Text
        var4 = TextBox11.Text
        var5 = ComboBox7.Text & ComboBox8.Text & ComboBox9.Text & ComboBox10.Text & ComboBox11.Text
        var6 = TextBox22.Text
        var7 = TextBox23.Text

        ListBox1.Items.Add(var1 & "---" & var2 & "---" & var3 & "---" & var4 & "---" & var5 & "---" & var6 & "---" & var7 & "---")
        WriteLine(1, var1, var2, var3, var4, var5, var6, var7)
        FileClose(1)
    End Sub
End Class


 Step 3 : Berikut hasil ketika kita sudah input datanya







 

Selasa, 05 April 2016

Membuat Form Pemesanan Tiket dengan VB

Hallo! Disini saya akan memberikan contoh bagaimana membuat program pemesan tiket konser menggunakan Visual Basic.

1. Buatlah design form Pemesanan Tiket konser sesuai dengan apa yang kamu inginkan atau buat seperti contoh di bawah ini

2. Masukkan Source Code seperti yang tertera di bawah.

Source Code

Public Class Form1

    Sub hapus()
        TxtNama.Text = ""
        TxtNoId.Text = ""
        ComboBoxTgl.Text = ""
        ComboBoxBln.Text = ""
        ComboBoxThn.Text = ""
        ComboBoxTiket.Text = ""
        TxtHarga.Text = ""
        ComboBoxBanyak.Text = ""
        TxtTotal.Text = ""
        TxtNama.Focus()
    End Sub

    Function total(ByVal HargaTiket, ByVal BanyakTiket)
        total = (HargaTiket * BanyakTiket)
    End Function

    Private Sub BtnHapus_Click(sender As Object, e As EventArgs) Handles BtnHapus.Click
        Call hapus()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        For a = 1 To 31
            ComboBoxTgl.Items.Add(a)
        Next
        For b = 1 To 12
            ComboBoxBln.Items.Add(b)
        Next
        For c = 1997 To 1966 Step -1
            ComboBoxThn.Items.Add(c)
        Next

        Dim i As Integer
        ComboBoxBanyak.Items.Clear()
        i = 4
        While i > 0
            ComboBoxBanyak.Items.Add(i)
            i -= 1
        End While
    End Sub

    Private Sub BtnBeli_Click(sender As Object, e As EventArgs) Handles BtnBeli.Click
        Dim x = MsgBox("Yakin Anda Telah Selesai Melakukan Pemesanan?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Konfirmasi")
        If x = vbYes Then
            Me.Close()
        End If
    End Sub

    Private Sub BtnLihat_Click(sender As Object, e As EventArgs) Handles BtnLihat.Click
        Form2.Show()
    End Sub

    Private Sub BtnTotal_Click(sender As Object, e As EventArgs) Handles BtnTotal.Click
        TxtTotal.Text = total(TxtHarga.Text, ComboBoxBanyak.Text)
    End Sub

    Private Sub TxtHarga_TextChanged(sender As Object, e As EventArgs) Handles TxtHarga.TextChanged
        If ComboBoxTiket.Text = "Daily Pass 4 Maret 2016" Then
            TxtHarga.Text = "550000"
        ElseIf ComboBoxTiket.Text = "Daily Pass 5 Maret 2016" Then
            TxtHarga.Text = "550000"
        ElseIf ComboBoxTiket.Text = "Daily Pass 6 Maret 2016" Then
            TxtHarga.Text = "550000"
        ElseIf ComboBoxTiket.Text = "3 Days Pass 4-6 Maret 2016" Then
            TxtHarga.Text = "1400000"
        Else
            TxtHarga.Text = "1250000"
        End If
    End Sub

    Private Sub Label9_Click(sender As Object, e As EventArgs) Handles Label9.Click
        Select Case ComboBoxBanyak.Text
            Case 1
                Label9.Text = "Anda mendapatkan 1 tiket"
            Case 2
                Label9.Text = "Anda mendapatkan 2 tiket"
            Case 3
                Label9.Text = "Anda mendapatkan 3 tiket"
            Case Else
                Label9.Text = "Anda mendapatkan 3 tiket"
        End Select
    End Sub
End Class


3. Dan inilah hasilnya jika klik button Total

4. Jika klik tombol lihat yang akan keluar jadi seperti ini



Rabu, 23 Maret 2016

Membuat Array dengan C#

1. Buatlah form dengan C# dan pilih "Console Application"


2. Lalu masukkan coding seperti contoh berikut:


3. Dan inilah hasilnya



Membuat Progress Bar dengan C#

1. Buatlah form sesuai yang anda inginkan dan jangan lupa tambahkan "Progress Bar" yang terdapat di Toolbox



2. Masukkan coding sesuai yang diingkan seperti contoh berikut:


3. Dan hasilnya akan seperti ini jika yang di entry adalah sebuah angka


Selamat Mencoba!

Membuat IF ELSE dengan C#

1. Buatlah form sesuai yang anda inginkan, seperti contoh ini


2. Kemudian klik button untuk memasukkan source code yang diinginkan


contoh coding di atas adalah sebagai berikut:


Dan hasilnya jika ia memasukkan kata "Merah", "Biru", "Kuning", "Hijau" maka hasilnya akan benar, selain itu salah



Membuat form sederhana menggunakan C#

1. Buatlah form dengan C# dan pilih "Windows Form Application"


2. Form kosong akan muncul dan anda dapat memulai membuat form sesuai dengan apa yang anda inginkan
3. Gunakan toolbar untuk mendesain form anda, seperti contoh berikut:



Selamat Mencoba!