Beruflich Dokumente
Kultur Dokumente
Contoh(1) Contoh(2)
1.Value 2. Plus
‘ Commentar dapat ditulis dengan diawali oleh apostrophe (‘)
‘ Baris lanjutkan di bawahnya dengan memberi: _ ( Underscore )
Sub subPlus()
Application.ActiveWorkbook. _
Sub subValue() Worksheets(1).Cells(1, 3).Value = _
Application.ActiveWorkbook. _ Application.ActiveWorkbook. _
Worksheets(1).Cells(1, 1).Value = 1 Worksheets(1).Cells(1, 1).Value + _
End Sub Application.ActiveWorkbook. _
Worksheets(1).Cells(1, 2).Value
Private Sub Worksheet_Activate()
End Sub
Application.ActiveWorkbook. _
Worksheets(1).Cells(1, 1).Value = 1
End Sub
Contoh(3) Contoh(4)
3. Full Name 4. Message Box
Sub subFullName() Sub subMessageBox()
Application.ActiveWorkbook. _ ‘ keyboard ENTER dinyatakan dengan ( Chr(13) & Chr(10)) atau vbCrLf
Worksheets(1).Cells(1, 3).Value = _
MsgBox "Maintenance Department"
Application.ActiveWorkbook. _
Worksheets(1).Cells(1, 1).Value & _ MsgBox "Maintenance Department", vbCritical
MsgBox "Maintenance" & VBA.Constants.vbCrLf & "Department"
“, “ & _
MsgBox "Maintenance" & vbCrLf & "Department"
Application.ActiveWorkbook. _
End Sub
Worksheets(1).Cells(1, 2).Value
End Sub
1
14/08/2013 - IrDarmadiMM
Contoh(5) Contoh(6)
1.Value 2. Plus
Public Function funSetValue() As Byte Public Function funPlus _
funSetValue = 1 (aInput As Currency, _
End Function bInput As Currency) _
As Currency
Public Function funSetValue _
(intInput As Integer) As Byte funPlus = aInput + bInput
funSetValue = 1
End Function End Function
Contoh penggunaan
Contoh(7) Function , Call Sub-Routine
3. Full Name Private Sub subMessageBox(blnType As Boolean)
If blnType = True Then
Public Function funFullName _ Dim strMSG As String
(strFirstName As String, _ strMSG = funFullName("Parviz", "Habibi")
strLastName As String) _ MsgBox strMSG
As String Else
MsgBox "HSP"
funFullName = strFirstName & _ End If
", " & strLastName End Sub
End Function
2
14/08/2013 - IrDarmadiMM
3
14/08/2013 - IrDarmadiMM
4
14/08/2013 - IrDarmadiMM
frm
.Interior.Color = VBA.ColorConstants.vbGreen
MsgBox .Count
End With
End Sub
frmMain.Show
Sub With2()
Dim myRange As Range
Unload ProjectGlobal.frmSandClock
Set myRange = VBAProject.Sheet1.Range("A1:D4")
With myRange With ProjectGlobal.frmExport
.Value = 123
MsgBox .Count .Left = Application.UsableWidth - .Width
End With .Top = Application.UsableHeight / 6
End Sub
End With
Penggunaan COMTROL
Contoh(18) Penggunaan Dim Contoh(24)
Private Sub txtLastName_Change() Sub countSubTasks()
Dim FirstName As String
Dim LastName As String Dim TSK As Task
Dim FullName As String Dim tCounter As Byte
FirstName = txtFirstName.Text
'tCounter = 0
LastName = txtLastName.Text
FullName = FirstName & " " & LastName For Each TSK In Application.ActiveProject.Tasks
txtFullName.Text = FullName If Not TSK Is Nothing Then
End Sub
TSK.Text12 = ""
Private Sub cmdStatsPrintPreview_Click() If TSK.Summary = False Then
'print tCounter = tCounter + 1
With VBAProject.Sheet4.PageSetup
If VBAProject.Sheet1.optPortrait.Value = True Then
TSK.Text12 = tCounter
.Orientation = xlPortrait End If
Else End If
.Orientation = xlLandscape
End If
Next TSK
End With MsgBox tCounter
VBAProject.Sheet4.PrintPreview End Sub
End Sub