Selasa, 28 Agustus 2018

CONTOH SOAL VISUAL BASIC





Inilah listing program berdasarkan komponen yang digunakan:
  • Combobox1:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Select Case ComboBox1.Text
Case “Nasi Uduk”
Label2.Text = “Rp. 3500”
hrgmakanan = 3500
Case “Bakso”
Label2.Text = “Rp. 6000”
hrgmakanan = 6000
Case “Mie Ayam”
Label2.Text = “Rp. 7000”
hrgmakanan = 7000
End Select
End Sub
  • variabel di Form1:
Public Class Form1
Public hrgmakanan, hrgminuman As Integer
  • Combobox2:
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Select Case ComboBox2.Text
Case “Es Jeruk”
Label4.Text = “Rp. 3000”
hrgminuman = 3000
Case “Jus Alpukat”
Label4.Text = “Rp. 7000”
hrgminuman = 7000
Case “Teh Manis”
Label4.Text = “Rp. 4000”
hrgminuman = 4000
End Select
End Sub

  • Sub-routine Public:
Public Sub New()
‘ This call is required by the designer. InitializeComponent()
ComboBox2.Visible = False
Label3.Visible = False
‘ Add any initialization after the InitializeComponent() call.
End Sub
  • Checkbox1:
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Enabled = False Then
ComboBox2.Visible = False
End If
If CheckBox1.Enabled = True Then
ComboBox2.Visible = True
Label3.Visible = True
End If
End Sub
  • Button1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim porsimkn, porsimnm, jumlah As Integer
porsimkn = TextBox1.Text
porsimnm = TextBox2.Text
jumlah = (hrgmakanan * porsimkn) + (hrgminuman * porsimnm)
Label7.Text = “Rp. ” & jumlah.ToString
End Sub

Tidak ada komentar:

Posting Komentar

relasi database my sql

  oke kali ini saya akan membuat artikel tentang Membangun Relasi Database 20-02-2019 Relational database merupakan model database y...