Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sending a HTTP Request using VB6

Posted on 2001-08-05
10
Medium Priority
?
10,938 Views
Last Modified: 2008-03-03
Hi all!

I need to send a HTTP request to a certain asp file on the internet so as to trigger a action like sending emails, etc...

how should i do it??

thanks a million
0
Comment
Question by:boonhui78
[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
  • 3
  • 3
  • 3
  • +1
10 Comments
 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6354698
Put an inet transfer control (microsoft internet transfer controls)

inet1.Execute "http://website.com/page.asp", "POST", "TEST=TEST"
0
 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6354701
If that does not work, try this:
inet1.Execute "http://website.com/page.asp", "POST", "TEST=TEST", "Content-Type: application/x-www-form-urlencoded"
0
 

Author Comment

by:boonhui78
ID: 6354704
hi shankarkrupa!

i forgot to mention that my application is actually an activex dll... so it doesnt have any forms

so is it possible to create this object at run time?

thanks
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6354707
Of course, you can do it by latebinding...

Like this:

set inet1 = CreateObject("InetCtls.Inet.1")

then all those code...

Maybe, it is better to first place the inet1.cancel before all those codes, after creating the object...
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6354878
Following is the code I use. it needs at least IE 5 installed. the function makes use of the XMLHTTP object...if you want you can adjust it to make use of early binding instead of late binding like in the example.

Private Function GetHTML(url) As String
    Dim objXML As Object
    Set objXML = CreateObject("Microsoft.XMLHTTP")
    objXML.Open "GET", url, False
    objXML.send
    If (objXML.Status = 404) Then
        GetHTML = "404 Error"
    Else
        GetHTML = objXML.responseText
    End If

    Set objXML = Nothing
End Function

It sends the http request, and will return you the contents of that url, or a 404 error. The 404 error can be replaced by an err.raise, but that's all up to you to design it the way you want it to.

regards,
CJ
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6354933
Using XMLHTTP Object

Private Sub Send_HTTP_REquest
     Dim DataToSend As String
     Dim objXML As Object


     DateToSend = "id=1"

     Set objXML = CreateObject("Microsoft.XMLHTTP")
     objXML.Open("POST", "http://www.domain/your_page.asp", false)
     objXML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
     objXML.send DataToSend
End Sub


More information here
http://support.microsoft.com/support/kb/articles/Q290/5/91.ASP

hongjun
0
 

Author Comment

by:boonhui78
ID: 6358938
hi hongqiun!
that xml solution works however it removes all the spaces inside my data...

for example, if i set
DateToSend = "name=Eric Ang&body=Hello World"

i would recieve "EricAng", and "HelloWorld"

Any solutions??

Thanks

0
 
LVL 33

Accepted Solution

by:
hongjun earned 200 total points
ID: 6362265
Try this then

DateToSend = "name=Eric Ang&body=Hello World"
DateToSend = replace(DateToSend," ", "+")

hongjun
0
 

Author Comment

by:boonhui78
ID: 6362357
Hey Man! You are great!!

Thanks a million!
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6362369
I am still learning like everyone here.

hongjun
0

Featured Post

Technology Partners: 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 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