0

I created small app in visual studio to control my raspberry pi but when I press button second time the request is not sent.

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim URL As String
    Dim objRequest
    URL = "http://192.168.0.2:8070/PwrON"
    objRequest = CreateObject("MSXML2.XMLHTTP")
    objRequest.Open("GET", URL, False)
    objRequest.Send
    objRequest = Nothing
    URL = Nothing

End Sub

Can you please help? Thank you

user692942
  • 16,398
  • 7
  • 76
  • 175
Marian
  • 23
  • 1
  • 3
  • You’re missing `Set` on `objRequest`, surprised you don’t get the error `Object Variable or With block variable not set` change the line to `Set objRequest = CreateObject(“MSXML2.XMLHTTP”)`. When assigning object reference in VBScript you need to use `Set object_reference = ...`. – user692942 Dec 12 '18 at 17:28
  • Just realised this isn't even VBScript it’s VB.Net mixture of syntaxes and can not see it ever working. – user692942 Dec 12 '18 at 17:32
  • guys. code is working fine. i created app for each button that ends after execution. it is VB.NET yes. also the SET is not used anymore at least that was error I got when I used it that is why it is not there.. – Marian Dec 13 '18 at 13:54
  • Anyway I would appreciate if someone knows how to start it via button without ending application. – Marian Dec 13 '18 at 13:56
  • That maybe the case, but it is not [tag:vbscript] and you are not setting your object references properly for whatever flavor of VB *(I suspect its VB.Net)* you are using. It would appear [`Set` isn't supported in VB.Net](https://stackoverflow.com/q/1468890/692942) so i'll back away as VB.Net is not my strong point. In future please be more careful when tagging questions as VBScript and VB.Net are very different technologies. – user692942 Dec 13 '18 at 13:57
  • You have no error trapping! So you don't know if your getting a response or an error returned! – Zeddy Dec 14 '18 at 21:48
  • Similar question - Maybe it will resolve your issue ... https://stackoverflow.com/questions/308826/msxml2-xmlhttp-send-method-works-with-early-binding-fails-with-late-binding – Zeddy Dec 14 '18 at 21:53

0 Answers0