aplikasi ini adalah aplikasi pemesanan tiket andromeda airways. karena airways ini baru jadi hanya melayani sekali penerbangan saja. bila ditekan tombol BOOK NOW maka langsung terproses dan menyambung ke word dan excel
Screenshot
Source Code
Public Class Form1
Dim excelapp As New Microsoft.Office.Interop.Excel.Application
Dim myexcelbook As Microsoft.Office.Interop.Excel.Workbook
Dim wordapp As New Microsoft.Office.Interop.Word.Application
Dim myword As Microsoft.Office.Interop.Word.Document
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
myexcelbook = excelapp.Workbooks.Open("D:\ANDROMEDA AIRWAYS.xlsx")
excelapp.Range("A2").Value = TextBox1.Text
excelapp.Range("B2").Value = ComboBox1.Text
excelapp.Range("C2").Value = TextBox4.Text
excelapp.Range("D2").Value = TextBox2.Text
excelapp.Range("E2").Value = TextBox3.Text
excelapp.Range("F2").Value = TextBox5.Text
myexcelbook.SaveAs("D:\ANDORMEDA AIRWAYS2.xlsx")
excelapp.Visible = True
myword = wordapp.Documents.Open("D:\\RESERVATION ANDROMEDA AIRWAYS.docx")
myword.Bookmarks("NAME").Select()
wordapp.Selection.TypeText(TextBox1.Text)
myword.Bookmarks("GENDER").Select()
wordapp.Selection.TypeText(ComboBox1.Text)
myword.Bookmarks("PHONE").Select()
wordapp.Selection.TypeText(TextBox4.Text)
myword.Bookmarks("DESTINATION").Select()
wordapp.Selection.TypeText(ComboBox2.Text)
myword.Bookmarks("DEPARTURE").Select()
wordapp.Selection.TypeText(DateTimePicker2.Text)
myword.Bookmarks("CLASS").Select()
wordapp.Selection.TypeText(ComboBox3.Text)
If ComboBox3.Text = "PREMIUM" Then
TextBox6.Text = "15000000"
ElseIf ComboBox3.Text = "BUSINESS" Then
TextBox6.Text = "10000000"
ElseIf ComboBox3.Text = "ECONOMY" Then
TextBox6.Text = "5000000"
End If
TextBox7.Text = (TextBox6.Text * 0.05)
Dim total As Integer
total = Val(TextBox6.Text) + Val(TextBox7.Text)
TextBox8.Text = total
myword.Bookmarks("TOTAL").Select()
wordapp.Selection.TypeText(TextBox8.Text)
myword.SaveAs2("D:\\" + TextBox1.Text + ".docx")
wordapp.Visible = True
End Sub
Private Sub DateTimePicker2_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker2.ValueChanged
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
End Sub
End Class




Tidak ada komentar:
Posting Komentar