-2
Option Explicit

Public Sub save_url_contents_as_text()  
    Dim MyUrl As String  
    Dim MyFile As Object    'store the text file here  
    Dim tempstring As String

    MyUrl = "www.AnythingIWantToPutHere"

    'I want your help here. Something Like a function  
    tempstring = geturltext(MyUrl)

    'I want to save the URL text contents here  
    MyFile = tempstring

End Sub
djv
  • 15,168
  • 7
  • 48
  • 72
KoyKoy
  • 21
  • 3
  • Hi Guys, I've been in VB programming for almost a year due to the needs of where i am currently working and I've always find the best answers i am seeking in stackoverflow. Glad for your help. – KoyKoy Aug 08 '16 at 15:20
  • can you please specify the intended use of this code snippet? what you are trying to achieve what what is the exact problem you are facing. – Bamieh Aug 08 '16 at 15:23
  • Possible duplicate of [Download URL Contents Directly into String (VB6) WITHOUT Saving to Disk](http://stackoverflow.com/questions/10968946/download-url-contents-directly-into-string-vb6-without-saving-to-disk) – OldBoyCoder Aug 08 '16 at 19:27
  • Hard to say it's a duplicate if it's [hint] unclear what you're asking – djv Aug 08 '16 at 19:28
  • Here is the algorithm I am trying to code. I will use a car as an object example: 1. User Must input A Brand of Car and what type of Car. 2. The program will go to the website of that Car's brand 3. The program will get the details of the Car type he entered( ex: he entered 4X4 truck) 4. Then the program will display Engine type, Price, type f wheels, etc But in my actual program, The information I want to get is all displayed in html tables. Just need to get it's content, store in text file for easy manipulation, and Im good to go. That's how the program should work. – KoyKoy Aug 09 '16 at 15:35
  • 1
    If you look at the link I marked as a possible duplicate it shows how you can get the contents of a web page into a string. You should be able to work from there. If you can't then your question is too broad for SO. No-one here is going to write 'geturltext' for you. But if you have a try at writing it and then it doesn't work we'll help you fix it. – OldBoyCoder Aug 09 '16 at 20:37

1 Answers1

0

Taken directly from here. Change the URL and the filename as desired. This call writes the contents of the URL to a disk file.

This example shows how to use the URLDownloadToFile API function to download a file from a URL into a file in Visual Basic 6.

Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, _
ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Private Sub Form_Load()
  ' Download the file.
  URLDownloadToFile 0, _
    "http://www.vb-helper.com/vbhelper_425_64.gif", _
    "C:\vbhelper_425_64.gif", 0, 0

End Sub
MarkJ
  • 30,070
  • 5
  • 68
  • 111