?
Solved

Accessing Remote ASP Pages from VB Application(Client)

Posted on 2003-03-28
6
Medium Priority
?
289 Views
Last Modified: 2010-05-03
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
0
Comment
Question by:malli_akula
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8224244
Try this:

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_PRECONFIG = 0
Public Const INTERNET_FLAG_RELOAD = &H80000000
Public Const INTERNET_FLAG_KEEP_CONNECTION = &H400000
Public Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000

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_PRECONFIG, vbNullString, vbNullString, 0&)
    ping = False
    If hInet Then
        Flags = INTERNET_FLAG_KEEP_CONNECTION Or INTERNET_FLAG_NO_CACHE_WRITE Or INTERNET_FLAG_RELOAD
        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_PRECONFIG, vbNullString, vbNullString, 0&)
    isOnline = False
    If hInet Then
        Flags = INTERNET_FLAG_KEEP_CONNECTION Or INTERNET_FLAG_NO_CACHE_WRITE Or INTERNET_FLAG_RELOAD
        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
0
 

Expert Comment

by:tsravank
ID: 8224321
If your ASP url returns a value just include the below in your code.

Dim strURL As String
strURL = "URL"
msgbox (strURL)

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 8224821
How is returned the dat in asp page, inside the reslting html document or is a dll?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:CleanupPing
ID: 8531419
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.
0
 
LVL 6

Expert Comment

by:GPrentice00
ID: 9440828
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
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9495562
This question is PAQed and no points refunded (of 50)

YensidMod
Expert Exchange Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question