“Error Handle” dengan Visual Basic 6.0
Percontohan “Error Handle” yang terdapat pada blog “Yulis Riyadi”.
Tidak ada modifikasi yang dibuat. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Penanganan Kesalahan"
ClientHeight = 3090
ClientLeft = 45
ClientTop = 435
ClientWidth = 4680
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 2
Top = 2715
Visible = 0 'False
Width = 4680
_ExtentX = 8255
_ExtentY = 661
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.CommandButton Command1
Caption = "Keluar"
Height = 495
Index = 1
Left = 3240
TabIndex = 1
Top = 2280
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Open"
Height = 495
Index = 0
Left = 1733
TabIndex = 0
Top = 2280
Width = 1215
End
Begin VB.Image Image1
Height = 1935
Left = 240
Stretch = -1 'True
Top = 240
Width = 4215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
Dim Nama_Berkas, Pesan_Kesalahan As String
Dim Pernyataan As VbMsgBoxResult
On Error GoTo Ada_Kesalahan
Awal:
Image1.Picture = Nothing
Nama_Berkas = InputBox("Ketikan Alamat dan Nama Berkas Gambar :", "Buka Berkas Gambar", Nama_Berkas)
If Nama_Berkas <> Empty Then
Image1.Picture = LoadPicture(Nama_Berkas)
End If
Exit Sub
Ada_Kesalahan:
Select Case Err.Number
Case 53
Pesan_Kesalahan = "Berkas [" & Nama_Berkas & "] tidak ditemukan...!"
Case 71
Pesan_Kesalahan = "Disket belum dimasukkan !"
Case Else
Pesan_Kesalahan = Err.Description
End Select
Pernyataan = MsgBox(Pesan_Kesalahan, vbCritical + vbRetryCancel, Me.Caption)
Select Case Pernyataan
Case vbRetry
If Err.Number = 53 Then Resume Awal Else Resume
Case vbCancel
Resume Next
End Select
Case 1:
Unload Me
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Keluar program ?", vbQuestion + vbYesNo, "Perhatian") = vbNo Then
Cancel = 1
End If
End Sub
Unduh Kode Sumber
Label: VB6
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda