Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need assistance with my Visual Basic code. The code is an image because when I copy and paste, the code gets reformatted and messy

I need assistance with my Visual Basic code. The code is an image because when I copy and paste, the code gets reformatted and messy with no indentations. In my code, I am sending a hard-coded string to another device, but my problem is that the string is not sent until I stop my program. I do not want to have to stop my program in order for the string to be sent. Maybe it is a timer issue. I am not sure. When I enter my local host IP address 127.0.0.1, I immediately see the string though, without having to close the program. The reference I used for the code is from the following website, but I had to make changes to make the string hard-coded, and the IP address inputted by the user in a textbox. http://www.dreamincode.net/forums/topic/21431-p2p-connections/ image text in transcribed

File Edit View Project Build Debug Team Tools Test Analyze Window Help Full Screen Quick Launch (Ctrl+Q) Form1.vb" Form1.vb [Designl WindowsAppl f (Form1 Events) FormClosing EIrports System.Net.Sockets Irports System.Threading 3 Irports System.IO 1 reference Public Class Formi Dim Listener As New TcpListener (5825 Dim Client As New TcpClient Dim Message As String- Private Sub Forml Load (ByWal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListThreed As New Thread(New ThreadStart(Addressof Listening)) ListThread.Start() 12 13 End Sub 1 reference Private Sub Listening) 16 Listener.Start) End Sub O references Private Sub Button1 Click(ByVal sender As System.Object, ByVal e As Systen.EventArgs) Handles Button1.Click 19 Client New TcpClient (TextBox1.Text, 5825) Dim Writer As New Streamuriter(Client.GetstreamO) Nriter.Write(" RST") riter.Flush() End Sub 0 referenes Private Sub Timer1 Tick(ByWal sender As Systen.Object, ByVal e As System.EventAres) Handles Tiner1.Tick 25 If Listener.Pending True Then Message-* Client Listener.AcceptTcpClient) Din Reader As New StreanReader (C1ient.Getstream()) While Reader.Peek 1 End While MsgBox (Message, MsgBoxStyle.Okonly) 31 E 32 Message Message Convert . ToChar(Reader. Read().ToString 35 36 End If End Sub 0 refarences Private Sub TextBox1_TextChanged(sender As Object, e As EventAres) Handles Textbox1.TextChanged 38 39 End Sub o references Private Sub Label1 Click(sender As Object, e As EventArgs) Handles Label1.Click 43 End Sub 0 references 46? Private Sub Forml-FormClosing(ByVal sender As Object, Byval e As System.Windows.Forms , FormClosingEventArgs) Handles Me. FormClosing Listener.Stop() End Sub End Class 51 90% Ready Ln 46 Col 1 Ch 1 Add to Source Control File Edit View Project Build Debug Team Tools Test Analyze Window Help Full Screen Quick Launch (Ctrl+Q) Form1.vb" Form1.vb [Designl WindowsAppl f (Form1 Events) FormClosing EIrports System.Net.Sockets Irports System.Threading 3 Irports System.IO 1 reference Public Class Formi Dim Listener As New TcpListener (5825 Dim Client As New TcpClient Dim Message As String- Private Sub Forml Load (ByWal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListThreed As New Thread(New ThreadStart(Addressof Listening)) ListThread.Start() 12 13 End Sub 1 reference Private Sub Listening) 16 Listener.Start) End Sub O references Private Sub Button1 Click(ByVal sender As System.Object, ByVal e As Systen.EventArgs) Handles Button1.Click 19 Client New TcpClient (TextBox1.Text, 5825) Dim Writer As New Streamuriter(Client.GetstreamO) Nriter.Write(" RST") riter.Flush() End Sub 0 referenes Private Sub Timer1 Tick(ByWal sender As Systen.Object, ByVal e As System.EventAres) Handles Tiner1.Tick 25 If Listener.Pending True Then Message-* Client Listener.AcceptTcpClient) Din Reader As New StreanReader (C1ient.Getstream()) While Reader.Peek 1 End While MsgBox (Message, MsgBoxStyle.Okonly) 31 E 32 Message Message Convert . ToChar(Reader. Read().ToString 35 36 End If End Sub 0 refarences Private Sub TextBox1_TextChanged(sender As Object, e As EventAres) Handles Textbox1.TextChanged 38 39 End Sub o references Private Sub Label1 Click(sender As Object, e As EventArgs) Handles Label1.Click 43 End Sub 0 references 46? Private Sub Forml-FormClosing(ByVal sender As Object, Byval e As System.Windows.Forms , FormClosingEventArgs) Handles Me. FormClosing Listener.Stop() End Sub End Class 51 90% Ready Ln 46 Col 1 Ch 1 Add to Source Control

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Additional Factors Affecting Group Communication?

Answered: 1 week ago