dcsimg
December 4, 2016
Hot Topics:

Using the Internet Transfer Control: Part 2

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

Unfortunately there is no way to detect runtime errors, as the error numbers provided by the Err object do not match with the Inet controls error constants. For example, if you provide a url of "http://" with no error handling, then a runtime error occurs with the description of "URL is malformed." Now, the error constant icBadUrl is also described as URL is malformed, but the numbers just don't match. So, instead, we just have to tell the user.

When it comes to detecting connection errors etc, we are going to have more problems. The Inet control provides us with two properties for getting response information, these are:

  • ResponseCode
  • ResponseInfo

Now, ResponseInfo usually gives a string very similar to the name of the corresponding ic constant. But, the ResponseCode is different! What a pain. But, there is a small workaround. You can create a standard module that contains some string constants that contain the responses returned. Here is a sample constant:

Public Const UNRESOLVED As String = _
             "Name not resolved"

You can use this as follows:

Private Sub Inet1_StateChanged(ByVal State As Integer)

Select Case State

  Case icError
    SelectError Inet1.ResponseInfo

End Select

End Sub


Private Sub SelectError(errStr As String)

Select Case errStr

  Case UNRESOLVED
    Msgbox "The host name given could not be resolved."

End Select

End Sub

That's about it for this time, but in the next part I will take you through connecting to an FTP Server using the Inet control.

I have made a small demo project to accompany this article. It works to display errors that occur when using the Inet control.

Download the files





Page 4 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel