0% found this document useful (0 votes)
52 views3 pages

LATVB

This document contains code for several different programs and functions: 1) A factorial calculation program that uses a for loop to calculate the factorial of a number input in a text box. 2) A sales list program that uses select case statements to set pricing and discount variables based on an item selected from a list. 3) A star printing program that uses a for loop to print a number of asterisks input in a text box. 4) An array-based calculator that takes numeric input, performs basic math operations, and displays results. 5) A student name storage program that uses arrays and combo boxes to view and edit a list of student names.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views3 pages

LATVB

This document contains code for several different programs and functions: 1) A factorial calculation program that uses a for loop to calculate the factorial of a number input in a text box. 2) A sales list program that uses select case statements to set pricing and discount variables based on an item selected from a list. 3) A star printing program that uses a for loop to print a number of asterisks input in a text box. 4) An array-based calculator that takes numeric input, performs basic math operations, and displays results. 5) A student name storage program that uses arrays and combo boxes to view and edit a list of student names.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Faktorial Dim n As Integer Private Sub Command1_Click() n = Val(Text1.Text) Label3.

Caption = " " hasil = 1 For i = 1 To n hasil = hasil * i Next i Label3.Caption = hasil End Sub

Dim harga As Currency, total As Currency Dim jumlah As Integer Dim diskon As Single Dim satuan As String Select Case List1.Text Case "Disket" harga = 35000 satuan = "Box" Case "Buku" harga = 20000 satuan = "Lusin" Case "Kertas"

Jumlah bintang Comm 1 Dim b As String Dim i, a As Integer Private Sub Command1_Click() a = Text1.Text b = "*" hasil = " " For i = 1 To a

harga = 25000 satuan = "Rim" Case "Pulpen" harga = 10000 satuan = "Pak" End Select lblBarang.Caption = "Barang:" & List1.Text lblHarga.Caption = "harga:" & Format(harga, "Currency") & "/" & satuan lblJumlah.Caption = "Jumlah:" & Text1.Text & "" & satuan

hasil = hasil + b Label2.Caption = hasil jumlah = Text1.Text Next i End Sub Select Case jumlah Case Is < 10 Daftar Harga (select case) diskon = 0 Private Sub Command1_Click() Case 10 To 20 If Text1.Text = "" Then diskon = 0.15 MsgBox " Anda Harus Memasukkan Jumlah Barang" Case Else Text1.SetFocus diskon = 0.2 Exit Sub End Select End If

Case "*" total = jumlah * (harga * (1 - diskon)) hasil = angka(1) * angka(2) Case "/" lblDiskon.Caption = "Diskon : " & Format(diskon, "0%") lblTotal.Caption = "Total Bayar :" & Format(total, "Currency") End Sub hasil = angka(1) / angka(2) End Select Text1.Text = hasil End Sub Private Sub Form_Load() List1.AddItem "Disket" List1.AddItem "Buku" List1.AddItem "Kertas" List1.AddItem "Pulpen" End Sub Kalkulator sederhana Dim angka(1 To 2) As Single Dim operator As String Dim NamaSiswa() As String Private Sub Command1_Click() Private Sub CmdAngka_Click(Index As Integer) Text1.Text = Text1.Text & CmdAngka(Index).Caption End Sub Private Sub cmdHapus_Click() If NamaSiswa(no) <> "" Then Text1.Text = "" List1.Clear End Sub For i = 1 To UBound(NamaSiswa) List1.AddItem "NamaSiswa (" & i & ") = " & NamaSiswa(i) Private Sub cmdHitung_Click() Next i Dim hasil As Single End If If Text1.Text = "" Then Exit Sub End Sub angka(2) = CSng(Text1.Text) Select Case operator Array Combo Box Case "+" Private Sub Command2_Click() hasil = angka(1) + angka(2) Dim num As Integer, i As Integer Case "-" If Not IsNumeric(Text1.Text) Then Exit Sub hasil = angka(1) - angka(2) Dim no As Integer, i As Integer no = CInt(Combo1.Text) NamaSiswa(no) = InputBox("Tuliskan Nama Siswa no : " & no, "Input Nama Siswa") Private Sub cmdOperator_Click(Index As Integer) If Text1.Text = "" Then Exit Sub angka(1) = CSng(Text1.Text) operator = cmdOperator(Index).Caption Text1.Text = "" End Sub

List1.AddItem "angka" & i num = CInt(Text1.Text) Next i End Sub ReDim NamaSiswa(1 To num) Private Sub Command3_Click() Combo1.Clear List1.Clear For i = 1 To UBound(NamaSiswa) Combo1.AddItem i List1.AddItem "NamaSiswa(" & i & ")=" & NamaSiswa(i) Next i Combo1.ListIndex = 0 End Sub Private Sub Command4_Click() Private Sub Form_Load() Dim i As Integer ReDim NamaSiswa(1 To 5) For i = 1 To 5 Combo1.AddItem i Next i Combo1.ListIndex = 0 End Sub Pengulangan angka, huruf Private Sub Command1_Click() List1.Clear For i = 1 To 100 List1.AddItem "angka" & i Next i End Sub List1.Clear i = Asc("z") Do While i >= Asc("a") List1.AddItem "Huruf" & Chr(i) i=i-1 Loop End Sub List1.Clear i = Asc("a") Do Until i > Asc("z") List1.AddItem "huruf" & Chr(i) i=i+1 Loop End Sub

Private Sub Command2_Click() List1.Clear For i = 100 To 1 Step -2

You might also like