Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Try Catch and Object Not Declared
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Try Catch and Object Not Declared
Divers
Thread ID:
00805368
Message ID:
00805368
Vues:
119
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform