Hello, All!
I'm modifying some source code that I downloaded from
Planet-source-code a while back, and have a question about Try Catch
statements. Basically, I'm wondering if I can do a Try with multiple Catch
statements, or do I have to figure out how to embed Try Catch statements
into my code. The scenario is this (and I'll paste the actual code at the
bottom of this post). I'm modifying a web browser, and in the About Help
box, it has the "System Info" button. In the System Info button, there are
some GO TO statements that I want to get rid of. Plus, the SysInfoError
which is referred to by the GO TO statements doesn't tell you anything
except that an error happened.
What I'd like to do is put a Try at the beginning of the If-Then
statements, and for each possible error, put a Catch statement with a
message saying what the error is. I have a feeling, if I can't do that,
then a somewhat major rewrite of the subroutine is in order. Here's the
subroutine, and I appreciate any help that I can get. Also, If I end up
using snippets of code from here, I will definitely credit the poster.
Public Sub StartSysInfo()
On Error GoTo SysInfoErr
Dim rc As Integer
Dim SysInfoPath As String
' Try To Get System Info Program Path\Name From Registry...
If GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFO, gREGVALSYSINFO,
SysInfoPath) Then
' Try To Get System Info Program Path Only From Registry...
ElseIf GetKeyValue(HKEY_LOCAL_MACHINE, gREGKEYSYSINFOLOC, gREGVALSYSINFOLOC,
SysInfoPath) Then
' Validate Existance Of Known 32 Bit File Version
'UPGRADE_WARNING: Dir has a new behavior. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1041"'
If (Dir(SysInfoPath & "\MSINFO32.EXE") <> "") Then
SysInfoPath = SysInfoPath & "\MSINFO32.EXE"
' Error - File Can Not Be Found...
Else
GoTo SysInfoErr
End If
' Error - Registry Entry Can Not Be Found...
Else
GoTo SysInfoErr
End If
Call Shell(SysInfoPath, AppWinStyle.NormalFocus)
Exit Sub
SysInfoErr:
MsgBox("System Information Is Unavailable At This Time", MsgBoxStyle.OKOnly)
End Sub
Thank you again in advance.
With best regards, Patrick Dickey. E-mail: pd*********************@msn.com
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0521-3, 05/26/2005
Tested on: 5/27/2005 1:27:00 AM
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com