Results 1 to 2 of 2

Thread: Add error responce

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2003
    Posts
    6

    Add error responce

    I have written the function:
    Code:
       Public Function getInternetFile(ByVal fileURL As String) As String
    
            Dim webconnect As New Net.WebClient()
            Dim readFileURL As New IO.StreamReader(webconnect.OpenRead(fileURL))
            Dim fileInternetContents As String = readFileURL.ReadToEnd
            readFileURL.Close()
            webconnect.Dispose()
            Return fileInternetContents
    
        End Function
    Which opens and reads in a file on the internet.

    How do i add an error message. ie if the function is called but the fileURL value dosent exsist, then I want it to return an error message. At the moment it will just crash if fileURL is invalid!

    THanks!

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Use try catch blocks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width