Anda di halaman 1dari 9

Materi UTS Visual 

Basic
March 30th, 2007 at 3:45 am (Uncategorized)

LATIHAN-1
Buat form sbb:

Listing program

Private Sub cmdselesai_Click()


End
End Sub

Private Sub cmdtampil_Click()


Text1.Text = “Agus Junaidi”
Text1.FontSize = 14
Text1.FontBold = True
Text1.ForeColor = vbBlue
Text1.BackColor = vbYellow
End Sub

LATIHAN-2
Buat form sbb:
Listing program

Private Sub cmdketik_Click()


Text1.Enabled = True
Text1.SetFocus
End Sub

Private Sub cmdselesai_Click()


a = MsgBox(”Yakim mau keluar”, vbOKOnly, “Perhatian”)
If a = vbOK Then End
End Sub

Private Sub Form_Activate()


Text1.Enabled = False
End Sub

Private Sub Option1_Click()


Text1.ForeColor = vbBlue
End Sub

Private Sub Option2_Click()


Text1.ForeColor = vbYellow
End Sub
Private Sub Option3_Click()
Text1.ForeColor = vbGreen
End Sub

Private Sub Option4_Click()


Text1.ForeColor = vbRed
End Sub

Private Sub Option5_Click()


Text1.FontBold = False
Text1.FontItalic = True
Text1.FontUnderline = False
End Sub

Private Sub Option6_Click()


Text1.FontBold = True
Text1.FontItalic = False
Text1.FontUnderline = False
End Sub

Private Sub Option7_Click()


Text1.FontBold = False
Text1.FontItalic = False
Text1.FontUnderline = True
End Sub

LATIHAN-3
Buat form sbb:
Listing progListing program
Dim teks As String
Dim k As Integer
Private Sub cbokode_click()
If cbokode.Text = “TV01″ Then
txtnama.Text = “TV Toshiba”
txtharga.Text = 700000
ElseIf cbokode.Text = “TV02″ Then
txtnama.Text = “TV Sony”
txtharga.Text = 900000
Else
txtnama.Text = “TV Akari”
txtharga.Text = 600000
End If
txtjumlah.SetFocus
End Sub
Private Sub cmdmulai_Click()
cbokode.Text = “”
txtnama.Text = “”
txtharga.Text = “”
txtjumlah.Text = “”
txttotal.Text = “”
txtbayar.Text = “”
txtkembali.Text = “”
End Sub
Private Sub cmdselesai_Click()
a = MsgBox(”Mau Keluar”, vbOKCancel, “Perhatian”)
If a = vbOK Then Unload Me
End Sub
Private Sub Form_Activate()
cbokode.AddItem “TV01″
cbokode.AddItem “TV02″
cbokode.AddItem “TV03″
End Sub

Private Sub Form_Load()


k=1
teks = frmtelevisi.Caption
End Sub

Private Sub Timer1_Timer()


frmtelevisi.Caption = Left(teks, k)
If k = Len(teks) Then
k=1
Else
k=k+1
End If
End Sub

Private Sub txtbayar_LostFocus()


txtkembali.Text = Val(txtbayar.Text) - Val(txttotal.Text)
End Sub

Private Sub txtjumlah_Change()


txttotal.Text = Val(txtjumlah.Text) * Val(txtharga.Text)
End Sub

Private Sub txtjumlah_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then txtbayar.SetFocus
End Sub

LATIHAN-4
Buat form sbb:

Listing program

Dim bayar, harga As Single

Private Sub cbotype_Click()


Select Case cbotype.ListIndex
Case 0
txtjenis.Text = “Vega R”
txtharga.Text = 10000000
Case 1
txtjenis.Text = “Jupiter Z”
txtharga.Text = 12000000
Case Else
txtjenis.Text = “Nouvo”
txtharga.Text = 13000000
End Select
txtnama.SetFocus
End Sub

Private Sub cmdmulai_Click()


cbotype.Text = “”
txtjenis.Text = “”
txtharga.Text = “”
txtnama.Text = “”
txtalamat.Text = “”
optcash.Value = False
optkredit.Value = False
txtbayar.Text = “”
End Sub

Private Sub cmdselesai_Click()


Unload Me
End Sub

Private Sub Form_Activate()


cbotype.AddItem “YM01″
cbotype.AddItem “YM02″
cbotype.AddItem “YM03″
End Sub

Private Sub optcash_Click()


harga = txtharga.Text
bayar = harga - 0.1 * harga
txtbayar.Text = Format(bayar, “Rp ###,###,###”)
End Sub

Private Sub optkredit_Click()


harga = txtharga.Text
bayar = harga + 0.2 * harga
txtbayar.Text = Format(bayar, “Rp ###,###,###”)
End Sub

Private Sub txtnama_KeyPress(KeyAscii As Integer)


If KeyAscii = 13 Then txtalamat.SetFocus
End Sub
LATIHAN-5
Buat form sbb:

Listing program

Dim ctrl As Control

Private Sub cbotujuan_Click()


Select Case cbotujuan.ListIndex
Case 0
txtbiaya.Text = 200
Case 1
txtbiaya.Text = 500
End Select
txtkiriman.Text = Val(txtberat.Text) * Val(txtbiaya.Text)
End Sub

Private Sub cmdselesai_Click()


Unload Me
End Sub

Private Sub cmdulang_Click()


For Each ctrl In Me
If TypeName(ctrl) = “TextBox” Then ctrl.Text = “”
If TypeName(ctrl) = “ComboBox” Then ctrl.Text = “”
If TypeName(ctrl) = “OptionButton” Then ctrl.Value = False
Next
End Sub

Private Sub Form_Activate()


cbotujuan.AddItem “DOMESTIK”
cbotujuan.AddItem “MANCANEGARA”
End Sub

Private Sub optbiasa_Click()


txttotal.Text = Val(txtkiriman.Text)
End Sub

Private Sub optkilat_Click()


txttotal.Text = Val(txtkiriman.Text) + 5000
End Sub

LATIHAN- 6
Buat form sbb:

Listing program

Private Sub cmdbersih_Click()


txtnama.Text = “”
optvip.Value = False
optteladan.Value = False
optbiasa.Value = False
txtjenis.Text = “”
lbljenis.Caption = “”
txtlama.Text = “”
txtbiaya.Text = “”
txttotal.Text = “”
End Sub

Private Sub cmdtutup_Click()


msg = MsgBox(”Yakin Keluar”, vbOKOnly, “Perhatian”)
If msg = vbOK Then
Unload Me
End If
End Sub

Private Sub optbiasa_Click()


txtbiaya.Text = 12000
End Sub

Private Sub optteladan_Click()


txtbiaya.Text = 75000
End Sub

Private Sub optvip_Click()


txtbiaya.Text = 150000
End Sub

Private Sub txtjenis_Change()


If txtjenis.Text = “1″ Then
lbljenis.Caption = “BEDAH”
ElseIf txtjenis.Text = “2″ Then
lbljenis.Caption = “INTERNIST”
Else
lbljenis.Caption = “GINEKOLOGI”
End If
End Sub

Private Sub txtlama_Change()


txttotal.Text = Val(txtlama.Text) * Val(txtbiaya.Text)
End Sub

ram

Anda mungkin juga menyukai