Public Class Form2
Dim excelApp As New Microsoft.Office.Interop.Excel.Application
Dim excelBook As Microsoft.Office.Interop.Excel.Workbook
Dim wordApp As New Microsoft.Office.Interop.Word.Application
Dim wordDoc As Microsoft.Office.Interop.Word.Document
untuk melakukan undian angka
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim acak As Integer
Randomize()
acak = (10000 * Rnd()) + 1
NoTiket.Text = acak
End Sub
untuk menyimpan data dalam excel dan word
Private Sub Button3_Click_1(sender As Object, e As EventArgs) Handles Simpan.Click
wordDoc = wordApp.Documents.Open("C:\Users\Lukman Hakim\Downloads\E-TIKET.docx")
wordDoc.Bookmarks("Type").Select()
wordApp.Selection.TypeText(ComboBox1.Text)
wordDoc.Bookmarks("Nama").Select()
wordApp.Selection.TypeText(Nama.Text)
wordDoc.Bookmarks("NomerTiket").Select()
wordApp.Selection.TypeText(NoTiket.Text)
wordDoc.SaveAs2("C:\Users\Lukman Hakim\Documents\" + Nama.Text + ".docx")
wordApp.Visible = True
excelBook = excelApp.Workbooks.Open("C:\Users\Lukman Hakim\Downloads\DATA TIKET.xlsx")
excelApp.Range("A2").Value = Nama.Text
excelApp.Range("B2").Value = Alamat.Text
excelApp.Range("C2").Value = Email.Text
excelApp.Range("D2").Value = TanggalLahir.Text
excelApp.Range("E2").Value = NoHP.Text
excelApp.Range("F2").Value = ComboBox1.Text
excelApp.Range("G2").Value = Harga.Text
excelApp.Range("H2").Value = NoTiket.Text
excelBook.SaveAs("C:\Users\Lukman Hakim\Documents\" + Nama.Text + ".xlsx")
excelApp.Visible = True
End Sub
untuk mengubah gambar sesuai dengan pesanan tiket
Private Sub ComboBox1_SelectedIndexChanged_1(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "Platinum" Then
Harga.Text = "600000"
End If
If ComboBox1.Text = "Platinum" Then
PictureBox1.Load("C:\Users\Lukman Hakim\Desktop\PLATINUM.JPG")
End If
If ComboBox1.Text = "Gold" Then
Harga.Text = "525000"
End If
If ComboBox1.Text = "Gold" Then
PictureBox1.Load("C:\Users\Lukman Hakim\Desktop\GOLD.JPG")
End If
If ComboBox1.Text = "Silver" Then
Harga.Text = "450000"
End If
If ComboBox1.Text = "Silver" Then
PictureBox1.Load("C:\Users\Lukman Hakim\Desktop\SILVER.JPG")
End If
If ComboBox1.Text = "Bronze" Then
Harga.Text = "400000"
End If
If ComboBox1.Text = "Bronze" Then
PictureBox1.Load("C:\Users\Lukman Hakim\Desktop\BRONZE.JPG")
End If
End Sub
End Class
Tidak ada komentar:
Posting Komentar