Go Premium for a chance to win a PS4. Enter to Win


How to communicate with a device (printer or something else) using an ethernet card>

Posted on 2007-09-09
Medium Priority
Last Modified: 2008-01-09
I have an instrument that communicate with an ethernet card (using a JAVA applet).  I am not new in VB programming but my experience with Internet/Ethernet communication is limited. The instrument/device response when using IE to commands with the form of "http:\\IP Address\command?"  I would like to use VB to send this command using a http connection and direct the return to a file of some sort. I guess what I am missing is the right control to use! Any advice will be greatly appreciated. Also, please avoid giving answers in terms of link to other pages as I will not bother looking.
Question by:khaledc
1 Comment
LVL 18

Accepted Solution

DarrenD earned 200 total points
ID: 19859671

So the device you wish to communicate with has an IP address. And you send commands to it using http and then get whatever the response is and write it out.

You'll have to change it so that it writes to a file though

Try this from MSDN

Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Namespace Examples.System.Net
    Public Class WebRequestGetExample

        Public Shared Sub Main()
            ' Create a request for the URL.        
            Dim request As WebRequest = WebRequest.Create("http://ipaddress/command?")
            ' Get the response.
            Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
            ' Display the status.
            ' Get the stream containing content returned by the server.
            Dim dataStream As Stream = response.GetResponseStream()
            ' Open the stream using a StreamReader for easy access.
            Dim reader As New StreamReader(dataStream)
            ' Read the content.
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Display the content.
            ' Cleanup the streams and the response.
        End Sub 'Main
    End Class 'WebRequestGetExample
End Namespace

Hope this helps


Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

926 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