Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!