Hi
I have below code & I want to convert it into module. 2 Parameters API & Port No will be passed.
It should return Image which is to be shown on Form.
Private Sub Command1_Click()
Dim objP As Object
Set objP = CreateObject("MSXML2.XMLHP")
Dim url As String
Dim username As String
Dim password As String
rl = "192.168.1.2:80/ISAPI/streaming/channels/01/picture"
username = "admin"
password = "12345."
objHP.Open "GET", rl, False, username, password
objHP.Send
Dim responseBody As Variant
responseBody = objHP.responseBody
' Save the image to a file
Dim outputStream As Object
Set outputStream = CreateObject("ADODB.Stream")
outputStream.Type = 1 ' Binary
outputStream.Open
outputStream.Write responseBody
outputStream.SaveToFile "C:\image.jpg", 2 ' 2: Overwrite if exists
outputStream.Close
' Dim img As StdPicture
' Set img = LoadPicture("C:\image.jpg") ' Load your image here
'
' Dim newWidth As Integer
' Dim newHeight As Integer
' newWidth = 5# * Screen.TwipsPerPixelX * 5#
' newHeight = 5 * Screen.TwipsPerPixelY * 5#
'
' Set Picture1.Picture = img
' Picture1.AutoRedraw = True
' Picture1.PaintPicture img, 0, 0, newWidth, newHeight
' Picture1.AutoRedraw = False
CropAndSave Picture1, 500, 500, 1000, 1000, "C:\image.jpg"
End Sub
Thanks