title: Write web pages contents to text file
body: <p>I am used to VBA but I never tried VB .NET and I need to get the text from 2 web pages to a text file. This is the code I am using, but I am having problems! What changes do I have to do to make it work?</p>
  
  <pre><code>Public mIE As Object
  Public arrText(1) As String
  Public Const myFile As String = "C:\myTextFile.txt"
  
  Public Sub Main()
      Dim arrURL(1) As String
      Dim i As Byte
  
      On Error Resume Next
      Kill (myFile)
  
      ' Define URL
      arrURL(0) = "http://URL1"
      arrURL(1) = "http://URL2"
  
      For i = 0 To 1
          'Spawn Internet Explorer
          mIE = CreateObject("InternetExplorer.Application")
  
          arrText(i) = openWebPage(arrURL(i))
  
          mIE.Quit()
          mIE.Close()
          mIE = Nothing
      Next
  
      Call saveToTextFile
  End Sub
  
  Public Function openWebPage(myURL As String) As String
      With mIE
          .Top = 0
          .Left = 0
          .Height = 800
          .Height = 600
          .AddressBar = 0
          .StatusBar = 0
          .Toolbar = 0
          .Visible = True
          .navigate (myURL)
      End With
  
      openWebPage = mIE.document.body.innerText
  End Function
  
  Public Sub saveToTextFile()
      Dim oWriter As New System.IO.StreamWriter(myFile )
      Dim i As Byte
  
      For i = 0 To UBound(arrText)
          oWriter.WriteLine (arrText(i))
      Next
  
      oWriter.Close()
  End Sub
  </code></pre>
  
  <p>Regards,
  Elio Fernandes</p>