Visual Basic Express 2008 Custom Error Message

C

Cass

I've programmed an autorun program. I would like to create a custom
error message when a person clicks on a button & the file is not in
the directory.

For example, the code for a button looks like this:
Private Sub filename_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles filename.Click
Shell("\file.exe", vbMaximizedFocus)
End Sub

If I remove file.exe from the directory because they hadn't, for
example, purchased the software, I want a custom error message to
appear.

Can anyone help me with the code for this?
 
T

Tom Shelton

I've programmed an autorun program. I would like to create a custom
error message when a person clicks on a button & the file is not in
the directory.

For example, the code for a button looks like this:
Private Sub filename_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles filename.Click
Shell("\file.exe", vbMaximizedFocus)
End Sub

If I remove file.exe from the directory because they hadn't, for
example, purchased the software, I want a custom error message to
appear.

Can anyone help me with the code for this?

If Not System.IO.File.Exists ("\file.exe") Then
' error message
Else
' shell
End If
 
C

Cass

If Not System.IO.File.Exists ("\file.exe") Then
        ' error message
Else
        ' shell
End If

So then would it end up like this?

Private Sub filename_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles filename.Click
Shell("\file.exe", vbMaximizedFocus)

If Not System.IO.File.Exists ("\file.exe") Then
' This File does not exist
Else
' shell
End If
End Sub
 
C

Cass

So then would it end up like this?

Private Sub filename_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles filename.Click
        Shell("\file.exe", vbMaximizedFocus)

If Not System.IO.File.Exists ("\file.exe") Then
        ' This File does not exist
Else
        ' shell
End If
    End Sub

NEVERMIND, I was being lazy. I've got it now. Thanks so much!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top