Visual Basic GetURL Command?

Importing data from a text file stored on a web server!

Page 1 of 1

2 Replies - 11632 Views - Last Post: 21 March 2008 - 09:48 AM Rate Topic: -----

#1 vengetic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-March 08

Visual Basic GetURL Command?

Posted 17 March 2008 - 08:39 AM

Hey, I’m wondering if any of you geniuses have a solution to this one.

I am a new AS level student studying computing at College, England. I am used to the idea of importing external content into Visual Basic using the code “Open App.Path & (“/Example/Example.txt”) for input as #1”. My question to you is, is it possible to import data from a .txt file stored on the internet.

I plan to retrieve information from a text file stored here”http://www.freewebs.com/d3v-t4y/Active.txt” then import this information into Visual Basic and execute it.

Devin Taylor

This post has been edited by vengetic: 17 March 2008 - 08:40 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Visual Basic GetURL Command?

#2 dave_6_10  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 19-March 08

Re: Visual Basic GetURL Command?

Posted 19 March 2008 - 02:57 PM

it is possible to import a .txt file from a url using the GetURL. However, expect some difficulty in getting a .txt file to run inside your VB environment, unless of course the .txt file is VB code. Good luck with your project.
Was This Post Helpful? 0
  • +
  • -

#3 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Visual Basic GetURL Command?

Posted 21 March 2008 - 09:48 AM

Quote

My question to you is, is it possible to import data from a .txt file stored on the internet.

Yes, we can.

What you need to use is the URLDownloadToFile() function from the urlmon Library.
Use it to download the text file to a location of your choice and the perform whatever operations you want on the downloaded file.

I've written this example for your case:
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 Command1_Click()
   Dim tmp as Long
   ' Replace c:\active.txt with the filename and path of your choice
   tmp = URLDownloadToFile(0, "http://www.freewebs.com/d3v-t4y/Active.txt", "c:\Active.txt", 0, 0)
End Sub

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1