Imports System.IO Imports System.Net.Sockets Public Class Form1 Dim listener As New TcpListener(44444) Dim client As TcpClient Dim message As String = "" Dim tts Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing listener.Stop() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load listener.Start() Timer1.Enabled = True Timer1.Start() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Try If listener.Pending = True Then message = "" client = listener.AcceptTcpClient() Dim Reader As New StreamReader(client.GetStream()) While Reader.Peek > -1 message = message + Convert.ToChar(Reader.Read()).ToString() End While Me.Focus() TextBox4.Text = (TextBox4.Text + message + vbCrLf) tts = CreateObject("sapi.spvoice") tts.speak(message) End If Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then MsgBox("Enter a user name, enter user IP", MsgBoxStyle.Information) Else client = New TcpClient(TextBox2.Text, 44444) Dim writer As New StreamWriter(client.GetStream()) writer.Write(TextBox1.Text + " Says! " + TextBox3.Text) writer.Flush() TextBox3.Text = "" End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged End Sub Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)