1) Buka Microsoft Visual basic, buat project baru, menu File > New Project.\
2) Pilih Visual Basic dan Windows Form Application. Buat nama project terserah Anda. Dan klik OK.
3) Setelah pembuatan project selesai maka akan muncul form yang masih kosong. Sesuaikan ukuran form dengan cara men-drag di pojok kanan bawah form.
4) Lalu tambahkan 7 button (tombol) dari toolbox sebelah kiri form. Lalu masukkan tombol ke dalam form.
5) Lalu tambah sebuah textbox dari toolbox
6) O iya! kita juga harus mengubah text pada 7 button tersebut. Caranya klik salah satu button, dan ganti text properties seperti ini
Ganti text tersebut dengan text di bawah ini :
button1 = back
button2 = forward
button3 = refresh
button4 = stop
button5 = go
button6 = add tab
button7 = close tab
7) Tambah sebuah tabcontrol dari toolbox dan hapus semua tabpages (tab1 dan tab2). Caranya klik 1 kali tabcontrol, di tabpages properties klik tombol[...]
8) Kemudian muncul dialog Tabpages Collection Editor, klik [Remove] untuk menghapus semua tabpage. Dan klik [OK]
9) Lalu klik kanan form dan klik View Code dan hapus semua code yang ada dan masukkan code ini :
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim tab As New TabPage
Dim brws As New WebBrowser
brws.Dock = DockStyle.Fill
tab.Text = " New Tab"
tab.Controls.Add(brws)
Me.TabControl1.TabPages.Add(tab)
Me.TabControl1.SelectedTab = tab
brws.Navigate("")
Catch ex As Exception
End Try
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Try
Dim tab As New TabPage
Dim brws As New WebBrowser
brws.Dock = DockStyle.Fill
tab.Text = "New Tab"
tab.Controls.Add(brws)
Me.TabControl1.TabPages.Add(tab)
Me.TabControl1.SelectedTab = tab
brws.Navigate("")
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Try
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
Catch ex As Exception
End Try
End Sub
Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TabControl1.Controls.Remove(TabControl1.SelectedTab)
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim tab As New TabPage
Dim brws As New WebBrowser
brws.Dock = DockStyle.Fill
tab.Text = " New Tab"
tab.Controls.Add(brws)
Me.TabControl1.TabPages.Add(tab)
Me.TabControl1.SelectedTab = tab
brws.Navigate("")
Catch ex As Exception
End Try
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Try
Dim tab As New TabPage
Dim brws As New WebBrowser
brws.Dock = DockStyle.Fill
tab.Text = "New Tab"
tab.Controls.Add(brws)
Me.TabControl1.TabPages.Add(tab)
Me.TabControl1.SelectedTab = tab
brws.Navigate("")
Catch ex As Exception
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Try
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
Catch ex As Exception
End Try
End Sub
Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
TabControl1.Controls.Remove(TabControl1.SelectedTab)
End Sub
Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub
End Class
10) Terakhir , Tekan Tombol F5
Dan Lihat Hasilnya
Video Lebih Lanjut Bisa Di Lihat Di Bawah Ini ::
Semoga Membantu !!
TERIMA KASIH
(***)
Tidak ada komentar:
Posting Komentar