Solved

vb6 talking to asp

Posted on 2006-06-14
7
290 Views
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?
0
Comment
Question by:jackjohnson44
  • 4
  • 3
7 Comments
 
LVL 1

Accepted Solution

by:
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 ("http://www.url.com/?i=" & 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.
0
 

Author Comment

by:jackjohnson44
ID: 16915415
is this .net?
0
 
LVL 1

Expert Comment

by:donald9
ID: 16915444
no. classic vb.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:jackjohnson44
ID: 16915483
Thanks

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

WebBrowser1.Navigate2 ("http://www.url.com/?i=" & variabletopass)

Private Sub WebBrowser1_NavigateComplete2
0
 
LVL 1

Expert Comment

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

Author Comment

by:jackjohnson44
ID: 16915552
so what calls the sub?
0
 
LVL 1

Expert Comment

by:donald9
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.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

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 …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

773 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