Visual Basic Ira
Form
Metode Form Load namaform ->membuka Unload namaform ->menutup Unload me ->menutup Namaform.show ->menampilkan form
KONDISI Select Case ekspresi If (kondisi) then Case nilai: End if ElseIf (kondisi) then ….ekspresi 2… Else ….ekspresi 3… Select Case ekspresi Case nilai: ….ekspresi 1… Case nilai : ….ekspresi 2… Case else nilai : ….ekspresi 3… End select
KONDISI
KONDISI Dim mark As Integer Dim grade As String Randomize Timer mark = Int(Rnd * 100) Cells(1, 1).Value = mark If mark < 20 And mark >= 0 Then grade = "F" Cells(2, 1).Value = grade ElseIf mark < 30 And mark >= 20 Then grade = "E" ElseIf mark < 40 And mark >= 30 Then grade = "D" ElseIf mark < 50 And mark >= 40 Then grade = "C-" Cells(2, 1).Value = grade ElseIf mark < 60 And mark >= 50 Then grade = "C" ElseIf mark < 70 And mark >= 60 Then grade = "C+" ElseIf mark < 80 And mark >= 70 Then grade = "B" ElseIf mark <= 100 And mark > -80 Then grade = "A" End If
KONDISI Select Case Grade Case Is >= 90 LetterGrade = "A" LetterGrade = "B" Case Is >= 70 LetterGrade = "C" Case Is >= 60 LetterGrade = "D" Case Else LetterGrade = "Sorry" End Select
LOOP Instruksi program yang memerintahkan suatu tugas diulang-ulang berdasarkan kondisi tertentu. Do While (kondisi) ….ekspresi … Loop 2. Do Until (kondisi) 3. For counter=nilai awal to nilaiakhir Next counter
LOOP For i = 1 to 10 Cells(i, 5) = i Next I For i = 1 to 10 Step 2 Do While i =< 10 Cells(i, 1) = i i = i + 1 Loop Do i = i + 1 Loop While i < 11
LOOP
INPUTBOX & MsgBOX Hasil=Inputbox(pesan,judul,default,intxpost,intypost) Msgbox(pesan,inttype,judul)
MsgBOX
MsgBOX Private Sub CommandButton4_Click() Dim message As Integer MsgBox ("Welcome to VBA Programming") End Sub Private Sub CommandButton3_Click() Dim message As Integer message = MsgBox("Click Yes to Proceed, No to stop", vbYesNoCancel, "Login") If message = 6 Then Range("D1").Value = "You may proceed" ActiveWorkbook.Activate ElseIf message = 7 Then ActiveWorkbook.Close End If Private Sub CommandButton4_Click() Dim message As Integer message = MsgBox("Click Yes to Proceed, No to stop", vbYesNo, "Login") If message = 6 Then Range("D2").Value = "You may proceed" ActiveWorkbook.Activate ElseIf message = 7 Then ActiveWorkbook.Close End If End Sub
Array Kumpulan data yang bertipe sama. Dim namaarray(2) as interger array(1)=“Bambang” array(2)=“Romi”
Array Dim Arr(6) Arr(1) = "Jan" Arr(2) = "Feb" Arr(3) = "Mar" Arr(4) = "Apr" Arr(5) = "May" Arr(6) = "Jun" MsgBox Arr(1) & "-" & Arr(2) & "-" & Arr(3) & "-" & Arr(4) & "-" & Arr(5) & "-" & Arr(6)
tugas
Numeric Data Types
Non-numeric Data Types