I have a fully functional "app" I created in Microsoft Access that I use control my Philips Hue lights. They operate via a RESTful interface using JSON commands and it was pretty simple to create the code in VBA. I wanted to make a standalone Windows app though so I can run it on my computers that don't have Access.
I'm trying to use Visual Studio 2015 to make a universal app using VB.net but I'm having problems converting some of my code over. I was able to fix most of the glitches, but I can't get the winHttpReq commands to work. In my research, it sounds like they don't have a direct correlation in VB.net but none of the suggestions I found have worked.
Dim Result As String
Dim MyURL As String, postData As String, strQuote As String
Dim winHttpReq As Object
winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
'Create address and lamp
MyURL = "http://" & IP.Text & "/api/" & Hex.Text & "/lights/" & "1" & "/state"
postData = Code.Text
winHttpReq.Open("PUT", MyURL, False)
winHttpReq.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
winHttpReq.Send(postData)
I get the error that 'CreateObject' is not declared. It may be inaccessible due to its protection level. I'm pretty new to VB.net coding but all the recommendations for alternative posting methods don't seem to work. Any suggestions would be greatly appreciated.