You are on page 1of 2

1.

TOMBOL ENTER

Private Sub TXTBIL_KeyPress()


If e.KeyChar = Chr(13) Then
If TXTBIL.Text >= 7 Then
MsgBox("ANDA LULUS")
Else
MsgBox("NO COMMENT")
End If
End If
End Sub

2. ON ERROR GOTO VAR


Private Sub BTN_PROSES_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BTN_PROSES.Click
On Error GoTo salah 'apabila error maka loncat ke ErrHandler:
Dim A As Integer
ListBox1.Items.Clear()
For A = 1 To TXTBIL.Text
ListBox1.Items.Add("Visual Basic")
Next
Exit Sub
salah:
MsgBox("Salah Input Data", MsgBoxStyle.Critical, "Perhatian")
'atau
‘MsgBox Err.Description
TXTBIL.Focus()
End Sub

3. ON ERROR GOTO 0
Private Sub BTN_PROSES_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BTN_PROSES.Click
On Error GoTo salah 'apabila error maka loncat ke ErrHandler:
Dim A As Integer
On Error GoTo 0
ListBox1.Items.Clear()
For A = 1 To TXTBIL.Text
ListBox1.Items.Add("Visual Basic")
Next
Exit Sub
salah:
MsgBox("Salah Input Data", MsgBoxStyle.Critical, "Perhatian")
'atau
‘MsgBox Err.Description
TXTBIL.Focus()
End Sub

4. ON ERROR GOTO RESUME NEXT


Private Sub BTN_PROSES_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BTN_PROSES.Click
On Error RESUME NEXT
Dim A As Integer
ListBox1.Items.Clear()
For A = 1 To TXTBIL.Text
ListBox1.Items.Add("Visual Basic")
Next
Exit Sub
End Sub

You might also like