Latihan 11 Visual Basic - Procedure Test
Dim Harga As Currency, Total As Currency
Private Sub TulisTeks(teks As String, Optional warna As ColorConstants = vbMagenta)
With Label1
.Caption = teks
.ForeColor = warna
End With
End Sub
Private Function JumlahAngka() As String
Dim angka1 As String, angka2 As String
Dim hasil As Single
angka1 = InputBox("Tulis angka 1 :", "Hitung Angka")
angka2 = InputBox("Tulis angka 2 :", "Hitung Angka")
If angka1 <> "" And angka2 <> "" Then
hasil = CSng(angka1) + CSng(angka2)
JumlahAngka = CStr(hasil)
End If
End Function
Private Sub HitungDiskon(ByVal HargaAwal As Currency, Diskon As Single)
HargaAwal = HargaAwal * (1 - Diskon)
Total = CCur(HargaAwal)
End Sub
Private Sub Label1_DblClick()
Call TulisTeks("Hai", vbBlue)
End Sub
Private Sub Command1_Click()
'Call TulisTeks("Hallo", vbRed)
Call TulisTeks("Hallo")
End Sub
Private Sub Command2_Click()
Label1.Caption = "Jumlah = " & JumlahAngka()
End Sub
Private Sub Command3_Click()
Harga = 10000
Total = 0
Call HitungDiskon(Harga, 0.1)
MsgBox "Harga " & Harga & " setelah diskon 10% menjadi " & Total
End Sub
2 komentar:
pa tugas vb 6 sudah beres latihan 11
nama:aji ragana
kelas:X RPL 1
Latihan 1,2,5,7,8,11 Nya beres
Nama:Tantan Anugerah
Kelas:XRPL1
Succes
:)
Posting Komentar