Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Visual Basic/VB.net, I am sending a command to another device. The command is :POWER? This command asks for the power reading on the device.

In Visual Basic/VB.net, I am sending a command to another device. The command is ":POWER?" This command asks for the power reading on the device. I am wondering, how can I get the reading for POWER displayed in a textbox in my GUI? I am able to perform the task in the windows command prompt, but I need to do this in the visual studio environment.

Imports System.Net.Sockets Imports System.Threading Imports System.IO Public Class Form1 Dim Listener As New TcpListener(23) 'telnet port number Dim Client As New TcpClient Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim ListThread As New Thread(New ThreadStart(AddressOf Listening)) ListThread.Start() End Sub Private Sub Listening() Listener.Start() 'open communication End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Client = New TcpClient("IP", Port) Dim Writer As New StreamWriter(Client.GetStream()) Writer.Write(":POWER?") Writer.Flush()

End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Listener.Stop() 'close communication End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

End Sub End Class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions