vb6 talking to asp

Posted on 2006-06-14
Last Modified: 2010-04-30
I have an asp page where there is a text box which I put in a number, do some work, then spit back another number.
It is a really crude valitdation thing that works pretty well.

I would like to be able to call the page in the background from a vb application and have the software read the number from the web.

So instead of someone going to my page, putting a number in a box, hitting submit, then copying and pasting the number back to the application, I would like to do it in the background.

I am using vb6.

How would I do this?
Question by:jackjohnson44
  • 4
  • 3

Accepted Solution

donald9 earned 500 total points
ID: 16914728
Add this control to your project:
Microsoft Internet Controls

Drag the "WebBrowser" to your form.

Use this code to navigate to the page:

WebBrowser1.Navigate2 ("" & variabletopass)

where variabletopass is the number you want to pass your ASP page.

Now, you need this subroutine

Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    verinfo = WebBrowser1.Document.documentelement.innerHTML
    verinfo = Replace(lcase(verinfo), "<html>", "")
    verinfo = Replace(lcase(verinfo), "<body>", "")
    verinfo = Replace(lcase(verinfo), "</body>", "")
    verinfo = Replace(lcase(verinfo), "</html>", "")
    verinfo = Replace(lcase(verinfo), "</head>", "")
    verinfo = Replace(lcase(verinfo), "</body>", "")
    verinfo = Replace(lcase(verinfo), "<head>", "")
    verinfo = Replace(lcase(verinfo), "<body>", "")
    verinfo = Replace(lcase(verinfo), " ", "")
    verinfo = Replace(lcase(verinfo), Chr(10), "")
    verinfo = Replace(lcase(verinfo), Chr(13), "")
End Sub

Now, the "verinfo" variable will have just the number that was passed from your ASP page as long as the ASP page is ONLY wrighting out that number. If it is writing out more than just that number you want, either remove the other info, create another page, or use the replace code above to remove the extra info.

Also, be sure your ASP page is using request.querystring instead of request.form

Hope that helps. Let me know if you need more help / clarification.

Author Comment

ID: 16915415
is this .net?

Expert Comment

ID: 16915444
no. classic vb.
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!


Author Comment

ID: 16915483

Should "WebBrowser1.Navigate2" and "WebBrowser1_NavigateComplete2" be the same?

WebBrowser1.Navigate2 ("" & variabletopass)

Private Sub WebBrowser1_NavigateComplete2

Expert Comment

ID: 16915505
no. they are different. The first is calling a function of the WebBrowser control. The second is creating a subroutine.

Author Comment

ID: 16915552
so what calls the sub?

Expert Comment

ID: 16915744
when you call the navigation function and tell it to go to a web page the control automatically passes back information to your application and that sub routine is called without you having to do anything once the web page has finished loading.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

713 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