Copy paste code program di bawah ini, kemudian coba jalankan. Jika file yang dimaksut ditemukan maka pesan yang akan ditampilkan adalah bernilai “True”, jika file yang dimaksud tidak ditemukan maka pesan yang akan di tampilakn bernilai False.

 

Function FileExists(strPath As String) As Boolean

Dim lngRetVal As Long

On Error Resume Next

lngRetVal = Len(Dir$(strPath, vbReadOnly Or _

                     vbSystem Or _

                     vbHidden Or _

                     vbArchive Or _

                     vbNormal))

                    

If Err Or lngRetVal = 0 Then

FileExists = False

Else

FileExists = True

End If

End Function

 

Private Sub Form_Load()

MsgBox FileExists(“C:\boot.ini”)

End Sub

 

 

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s