Click here to Skip to main content
15,906,329 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I find some online converter but when I put it on a C# some codes got an error.
VB
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
Posted
Comments
Tarakeshwar Reddy 23-Jan-12 11:59am    
I would suggest you ask about the specific error you are getting after using the online converter. The code is pretty straight forward and should not be that hard to convert
Sergey Alexandrovich Kryukov 23-Jan-12 15:07pm    
Agree.
--SA

1 solution

Use http://www.carlosag.net/tools/codetranslator/[^] and then ask if you have further issues.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900