malli_akula
asked on
Accessing Remote ASP Pages from VB Application(Client)
Hi,
I am working on an application in VB. The application has to perform calcuations on the remote webserver and get back the values to the VB application which i need to use in my application for further processing. The VB application is connected to the internet. My idea is if the VB can open an ASP residing in the remote webserver which could take care of calculations on the remote web server and return the value to the VB application.
regards.
Mallikarjun
I am working on an application in VB. The application has to perform calcuations on the remote webserver and get back the values to the VB application which i need to use in my application for further processing. The VB application is connected to the internet. My idea is if the VB can open an ASP residing in the remote webserver which could take care of calculations on the remote web server and return the value to the VB application.
regards.
Mallikarjun
If your ASP url returns a value just include the below in your code.
Dim strURL As String
strURL = "URL"
msgbox (strURL)
Dim strURL As String
strURL = "URL"
msgbox (strURL)
How is returned the dat in asp page, inside the reslting html document or is a dll?
Hi malli_akula,
This old question (QID 20566300) needs to be finalized -- accept an answer, split points, or get a refund. Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
This old question (QID 20566300) needs to be finalized -- accept an answer, split points, or get a refund. Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
-->PAQ - no points refunded
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER
GPrentice00
Cleanup Volunteer
I will leave a recommendation in the Cleanup topic area that this question is:
-->PAQ - no points refunded
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER
GPrentice00
Cleanup Volunteer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In a module:
Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal lpszAgent As String, ByVal dwAccessType As Long, ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, ByVal dwFlags As Long) As Long
Public Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInet As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Long
Public Const INTERNET_OPEN_TYPE_PRECONF
Public Const INTERNET_FLAG_RELOAD = &H80000000
Public Const INTERNET_FLAG_KEEP_CONNECT
Public Const INTERNET_FLAG_NO_CACHE_WRI
Public 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
Public Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Public Const ERROR_SUCCESS As Long = 0
Public Function ping(URL As String) As Boolean
Dim hInet As Long
Dim hUrl As Long
Dim Flags As Long
hInet = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONF
ping = False
If hInet Then
Flags = INTERNET_FLAG_KEEP_CONNECT
hUrl = InternetOpenUrl(hInet, URL, vbNullString, 0, Flags, 0)
If hUrl Then
ping = True
Call InternetCloseHandle(hUrl)
End If
End If
Call InternetCloseHandle(hInet)
End Function
Public Function DownloadFile(ByVal sURL As String, _
ByVal sLocalFile As String) As Boolean
On Error Resume Next
Dim lngRetVal As Long
'if the API returns ERROR_SUCCESS (0),
'return True from the function
'Delete the current file so that new file can be downloaded
Dim bool As Boolean
bool = DeleteUrlCacheEntry(sURL)
DoEvents
If isOnline Then
DownloadFile = URLDownloadToFile(0&, _
sURL, _
sLocalFile, _
0&, _
0&) = ERROR_SUCCESS
End If
End Function
Public Function isOnline() As Boolean
Dim hInet As Long
Dim hUrl As Long
Dim Flags As Long
Dim URL As Variant
hInet = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONF
isOnline = False
If hInet Then
Flags = INTERNET_FLAG_KEEP_CONNECT
hUrl = InternetOpenUrl(hInet, pingURL, vbNullString, 0, Flags, 0)
If hUrl Then
isOnline = True
Call InternetCloseHandle(hUrl)
End If
End If
Call InternetCloseHandle(hInet)
End Function
Test it like:
DeleteUrlCacheEntry "c:\abc.txt"
DownloadFile "http://localhost/test/abc.asp?id=123", "c:\abc.txt"
or
Randomize
DownloadFile "http://localhost/test/abc.asp?id=123&rand=" & int(rnd * 100000), "c:\abc.txt"
From this you should able to grab what the asp returned to local file.
Hope this helps