0
Pemrograman Visual
Posted by Unknown
on
17.18
in
Tutorial Blog
Gambar Desain:
di sini saya menggunakan:
- Label
- Combobox
- TextBox
- Button, dan
- ListBox
Ganti namenya seperti berikut.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loadkodebuku.Items.Add("LA-011")
kodebuku.Items.Add("VB-021")
kodebuku.Items.Add("VB-012")
kodebuku.Items.Add("LA-022")
Dim x As Integer
For x = 1 To 5
jumlah.Items.Add(x & "Exemplar")
Next
End Sub
Private Sub kodebuku_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebuku.SelectedIndexChanged
Dim x As String x = Microsoft.VisualBasic.Left(kodebuku.Text, 2)
Select Case x
Case "VB"
judul.Text = "Visual Basic.Net"
Case "LA"
judul.Text = "Logika dan Algoritma"
End Select
x = Microsoft.VisualBasic.Mid(kodebuku.Text, 5, 1)
Select Case x
Case "1"
penerbit.Text = "PT.Erlangga"
Case "2"
penerbit.Text = "CV.Logika Kreasi"
End Select
Select Case judul.Text
Case "Logika dan Algoritma"
Select Case penerbit.Text
Case "PT.Erlangga"
harga.Text = 30000
Case "CV.Logika Kreasi"
harga.Text = 35000
End Select
Case "Visual Basic.Net"
Select Case penerbit.Text
Case "PT.Erlangga"
harga.Text = 40000
Case "CV.Logika Kreasi"
harga.Text = 32000
End Select
End Select
End Sub
Private Sub jumlah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah.SelectedIndexChanged
Dim x As Byte
x = Microsoft.VisualBasic.Left(jumlah.Text, 1)
Select Case x
Case Is < 2
bonus.Text = 0
Case 2 To 4
bonus.Text = 1 / 100 * harga.Text
Case Is > 4
bonus.Text = 2 / 100 * harga.Text
End Select
If (harga.Text >= 35000) And (bonus.Text > 1500) Then
ppn.Text = 2 / 100 * harga.Text
Else
ppn.Text = 0
End If
End Sub
Private Sub bproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bproses.Click
total.Text = Val(harga.Text) + Val(bonus.Text) - (ppn.Text)
End Sub
Private Sub binput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles binput.Click
ListBox1.Items.Add(judul.Text & ":" & jumlah.Text & "=Rp." & total.Text)
End Sub
Private Sub bulang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bulang.Click
judul.Text = ""
kodebuku.Text = ""
penerbit.Text = ""
harga.Text = ""
jumlah.Text = ""
bonus.Text = ""
ppn.Text = ""
total.Text = ""
End Sub
End Class
jalan kan program.
maka, hasilnya seperti berikut:
Demikian artikel tentang Visual Basic
Posting Komentar