Untuk memenuhi tugas dari UTS Pemrograman Visual, saya membuat aplikasi sebuah input data Go-Food.
Dari rancangan pertama yang saya buat sedikit berbeda dengan yang sudah ada.
Pada rancangan pertama saya memakai fungsi : TextBox, Button, CheckBox, ComboBox.
Saya merubahnya menjadi : TextBox, Button, ComboBox, dan RadioButton serta menambah gambar hanya pada desain.
Untuk hasil run pada saat rancangan saya membuat Form1 untuk AutoWord dan Form2 AutoExcel.
Dan untuk yang saya buat saat ini saya membaliknya Form1 untuk Excel dan Form2 untuk Word, pada intinya fungsi ini sama hanya saja penampilannya saja yang saya rubah.
Berikut ScreenShoot dari Desain :
Form1
Form2
Untuk Script Coding pada Form1 :
Imports excel = Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For a = 1 To 31
cmbtgl.Items.Add(a)
Next
For a = 1 To 12
cmbbln.Items.Add(a)
Next
For a = 2030 To 2001 Step -1
cmbthn.Items.Add(a)
Next
End Sub
Sub bersih()
txtkepada.Clear()
txtnomor.Clear()
txtlokasi.Clear()
txtrate.Clear()
id1.Clear()
id2.Clear()
id3.Clear()
id4.Clear()
id5.Clear()
byk1.Clear()
byk2.Clear()
byk3.Clear()
byk4.Clear()
byk5.Clear()
hrg1.Clear()
hrg2.Clear()
hrg3.Clear()
hrg4.Clear()
hrg5.Clear()
txtjumlah.Clear()
txttotal.Clear()
End Sub
Private Sub btnhapus_Click(sender As Object, e As EventArgs) Handles btnhapus.Click
cmbbln.Text = ""
cmbtgl.Text = ""
cmbthn.Text = ""
menu1.Text = ""
menu2.Text = ""
menu3.Text = ""
RadioButton1.Checked = False
RadioButton2.Checked = False
menu4.Text = ""
menu5.Text = ""
cmbbln.Focus()
bersih()
End Sub
Private Sub btnnext_Click(sender As Object, e As EventArgs) Handles btninput.Click
Dim myExcelApp As New excel.Application
Dim myExcelBook As excel.Workbook
myExcelApp.Visible = True
myExcelBook = myExcelApp.Workbooks.Open("G:\tugas uts\data.xlsx")
myExcelApp.Range("D5").Value = txtkepada.Text()
myExcelApp.Range("D6").Value = txtnomor.Text()
myExcelApp.Range("D7").Value = txtlokasi.Text()
myExcelApp.Range("K5").Value = cmbtgl.Text()
myExcelApp.Range("L5").Value = cmbbln.Text()
myExcelApp.Range("M5").Value = cmbthn.Text()
myExcelApp.Range("K6").Value = txtrate.Text()
myExcelApp.Range("B11").Value = id1.Text()
myExcelApp.Range("C11").Value = menu1.Text()
myExcelApp.Range("F11").Value = byk1.Text()
myExcelApp.Range("H11").Value = hrg1.Text()
myExcelApp.Range("B12").Value = id2.Text()
myExcelApp.Range("C12").Value = menu2.Text()
myExcelApp.Range("F12").Value = byk2.Text()
myExcelApp.Range("H12").Value = hrg2.Text()
myExcelApp.Range("B13").Value = id3.Text()
myExcelApp.Range("C13").Value = menu3.Text()
myExcelApp.Range("F13").Value = byk3.Text()
myExcelApp.Range("H13").Value = hrg3.Text()
myExcelApp.Range("B14").Value = id4.Text()
myExcelApp.Range("C14").Value = menu4.Text()
myExcelApp.Range("F14").Value = byk4.Text()
myExcelApp.Range("H14").Value = hrg4.Text()
myExcelApp.Range("B15").Value = id5.Text()
myExcelApp.Range("C15").Value = menu5.Text()
myExcelApp.Range("F15").Value = byk5.Text()
myExcelApp.Range("H15").Value = hrg5.Text()
myExcelApp.Range("N10").Value = txtjumlah.Text()
myExcelApp.Range("N12").Value = txttotal.Text()
myExcelBook.SaveAs("G:\tugas uts\data_1.xlsx")
End Sub
Private Sub btnjumlah_Click(sender As Object, e As EventArgs) Handles btnjumlah.Click
Dim banyak1, banyak2, banyak3, banyak4, banyak5, harga1, harga2, harga3, harga4, harga5, hasil As Integer
banyak1 = byk1.Text
banyak2 = byk2.Text
banyak3 = byk3.Text
banyak4 = byk4.Text
banyak5 = byk5.Text
harga1 = hrg1.Text
harga2 = hrg2.Text
harga3 = hrg3.Text
harga4 = hrg4.Text
harga5 = hrg5.Text
hasil = (banyak1 * harga1) + (banyak2 * harga2) + (banyak3 * harga3) + (banyak4 * harga4) + (banyak5 * harga5)
txtjumlah.Text = hasil
End Sub
Private Sub menu1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles menu1.SelectedIndexChanged
If menu1.SelectedItem = "Bakso Urat" Then
hrg1.Text = "20000"
End If
If menu1.SelectedItem = "Mie Ayam" Then
hrg1.Text = "15000"
End If
If menu1.SelectedItem = "Mie Ayam Bakso" Then
hrg1.Text = "25000"
End If
If menu1.SelectedItem = "Soto Ayam" Then
hrg1.Text = "15000"
End If
If menu1.SelectedItem = "Soto Daging" Then
hrg1.Text = "20000"
End If
If menu1.SelectedItem = "Bebek Goreng/ Bakar" Then
hrg1.Text = "35000"
End If
If menu1.SelectedItem = "Ayam Goreng/ Bakar" Then
hrg1.Text = "20000"
End If
If menu1.SelectedItem = "Gurame Goreng/ Bakar" Then
hrg1.Text = "45000"
End If
If menu1.SelectedItem = "Bawal Goreng/ Bakar" Then
hrg1.Text = "20000"
End If
If menu1.SelectedItem = "Lele Goreng/ Bakar" Then
hrg1.Text = "15000"
End If
End Sub
Private Sub menu2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles menu2.SelectedIndexChanged
If menu2.SelectedItem = "Bakso Urat" Then
hrg2.Text = "20000"
End If
If menu2.SelectedItem = "Mie Ayam" Then
hrg2.Text = "15000"
End If
If menu2.SelectedItem = "Mie Ayam Bakso" Then
hrg2.Text = "25000"
End If
If menu2.SelectedItem = "Soto Ayam" Then
hrg2.Text = "15000"
End If
If menu2.SelectedItem = "Soto Daging" Then
hrg2.Text = "20000"
End If
If menu2.SelectedItem = "Bebek Goreng/ Bakar" Then
hrg2.Text = "35000"
End If
If menu2.SelectedItem = "Ayam Goreng/ Bakar" Then
hrg2.Text = "20000"
End If
If menu2.SelectedItem = "Gurame Goreng/ Bakar" Then
hrg2.Text = "45000"
End If
If menu2.SelectedItem = "Bawal Goreng/ Bakar" Then
hrg2.Text = "20000"
End If
If menu2.SelectedItem = "Lele Goreng/ Bakar" Then
hrg2.Text = "15000"
End If
End Sub
Private Sub menu3_SelectedIndexChanged(sender As Object, e As EventArgs) Handles menu3.SelectedIndexChanged
If menu3.SelectedItem = "Bakso Urat" Then
hrg3.Text = "20000"
End If
If menu3.SelectedItem = "Mie Ayam" Then
hrg3.Text = "15000"
End If
If menu3.SelectedItem = "Mie Ayam Bakso" Then
hrg3.Text = "25000"
End If
If menu3.SelectedItem = "Soto Ayam" Then
hrg3.Text = "15000"
End If
If menu3.SelectedItem = "Soto Daging" Then
hrg3.Text = "20000"
End If
If menu3.SelectedItem = "Bebek Goreng/ Bakar" Then
hrg3.Text = "35000"
End If
If menu3.SelectedItem = "Ayam Goreng/ Bakar" Then
hrg3.Text = "20000"
End If
If menu3.SelectedItem = "Gurame Goreng/ Bakar" Then
hrg3.Text = "45000"
End If
If menu3.SelectedItem = "Bawal Goreng/ Bakar" Then
hrg3.Text = "20000"
End If
If menu3.SelectedItem = "Lele Goreng/ Bakar" Then
hrg3.Text = "15000"
End If
End Sub
Private Sub menu4_SelectedIndexChanged(sender As Object, e As EventArgs) Handles menu4.SelectedIndexChanged
If menu4.SelectedItem = "Bakso Urat" Then
hrg4.Text = "20000"
End If
If menu4.SelectedItem = "Mie Ayam" Then
hrg4.Text = "15000"
End If
If menu4.SelectedItem = "Mie Ayam Bakso" Then
hrg4.Text = "25000"
End If
If menu4.SelectedItem = "Soto Ayam" Then
hrg4.Text = "15000"
End If
If menu4.SelectedItem = "Soto Daging" Then
hrg4.Text = "20000"
End If
If menu4.SelectedItem = "Bebek Goreng/ Bakar" Then
hrg4.Text = "35000"
End If
If menu4.SelectedItem = "Ayam Goreng/ Bakar" Then
hrg4.Text = "20000"
End If
If menu4.SelectedItem = "Gurame Goreng/ Bakar" Then
hrg4.Text = "45000"
End If
If menu4.SelectedItem = "Bawal Goreng/ Bakar" Then
hrg4.Text = "20000"
End If
If menu4.SelectedItem = "Lele Goreng/ Bakar" Then
hrg4.Text = "15000"
End If
End Sub
Private Sub menu5_SelectedIndexChanged(sender As Object, e As EventArgs) Handles menu5.SelectedIndexChanged
If menu5.SelectedItem = "Bakso Urat" Then
hrg5.Text = "20000"
End If
If menu5.SelectedItem = "Mie Ayam" Then
hrg5.Text = "15000"
End If
If menu5.SelectedItem = "Mie Ayam Bakso" Then
hrg5.Text = "25000"
End If
If menu5.SelectedItem = "Soto Ayam" Then
hrg5.Text = "15000"
End If
If menu5.SelectedItem = "Soto Daging" Then
hrg5.Text = "20000"
End If
If menu5.SelectedItem = "Bebek Goreng/ Bakar" Then
hrg5.Text = "35000"
End If
If menu5.SelectedItem = "Ayam Goreng/ Bakar" Then
hrg5.Text = "20000"
End If
If menu5.SelectedItem = "Gurame Goreng/ Bakar" Then
hrg5.Text = "45000"
End If
If menu5.SelectedItem = "Bawal Goreng/ Bakar" Then
hrg5.Text = "20000"
End If
If menu5.SelectedItem = "Lele Goreng/ Bakar" Then
hrg5.Text = "15000"
End If
End Sub
Private Sub btntotal_Click(sender As Object, e As EventArgs) Handles btntotal.Click
Dim hasil As Integer
Select Case txtrate.Text
Case 0.1
hasil = 0.1 * txtjumlah.Text
txttotal.Text = hasil
Case 0.15
hasil = 0.15 * txtjumlah.Text
txttotal.Text = hasil
End Select
End Sub
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
txtrate.Text = 0.1
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
txtrate.Text = 0.15
End Sub
Private Sub btnext_Click(sender As Object, e As EventArgs)
Form2.Show()
Me.Close()
End Sub
Private Sub btnnext_Click_1(sender As Object, e As EventArgs) Handles btnnext.Click
Form2.Show()
Me.Hide()
End Sub
End Class
Untuk Script Coding pada Form2 :
Imports word = Microsoft.Office.Interop.Word
Public Class Form2
Private Sub btnselesai_Click(sender As Object, e As EventArgs) Handles btnselesai.Click
Dim Appnya As New word.Application
Dim Dokumennya As word.Document
Dokumennya = Appnya.Documents.Open("G:\tugas uts\hasil.docx")
Dokumennya.Bookmarks("kepada").Select()
Appnya.Selection.TypeText(txtkpd.Text)
Dokumennya.Bookmarks("nomor").Select()
Appnya.Selection.TypeText(txtnoin.Text)
Dokumennya.Bookmarks("lokasi").Select()
Appnya.Selection.TypeText(txtlok.Text)
Dokumennya.Bookmarks("total").Select()
Appnya.Selection.TypeText(txttocf.Text)
Dokumennya.SaveAs2("G:\tugas uts\hasil1.docx")
Appnya.Visible = True
End Sub
Private Sub btnkeluar_Click(sender As Object, e As EventArgs) Handles btnkeluar.Click
Dim x = MsgBox("TERIMA KASIH SUDAH MELAKUKAN TRANSAKSI!", MsgBoxStyle.Information + MsgBoxStyle.Question, "INFORMASI")
Me.Close()
'End
End Sub
End Class
Berikut hasil dari Run :
Semoga bermanfaat :)
Wassalamualaikum...