Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Try Catch and Object Not Declared
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Try Catch and Object Not Declared
Miscellaneous
Thread ID:
00805368
Message ID:
00805368
Views:
118
If put some of my code in a try/Catch to prevent a connection error, but when I do that, it's telling me that the loConnect object is not defined. I understand it is being smart and that if the try fails, the object would not be created, but it makes the program is it won't run. How is the best way to overcome this.

Thanks
                ' Create a Connection Object
                Dim loFactory = CreateObject("S2TCPComms.TCPConnectionFactory")
                ' Connect to Remote Site
                Try
                    Dim loConnect = loFactory.Connect(sAddress, Val(sPort))
                    lConnectionOk = True
                Catch ex As Exception
                    lConnectionOk = False

                End Try
                If lConnectionOk Then
                    Try
                        loConnect.sendmessage(sParsedMessage)
                        ' Disconnect
                        loConnect.disconnect()
                    Catch ex As Exception
                    End Try
                End If
Next
Reply
Map
View

Click here to load this message in the networking platform