Il codice è questo:

Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Design
Imports System.Reflection
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Imports System.Net
Imports System.Net.Sockets

Public Partial Class MainForm
''' Dichiarazione oggetti
Dim client As New TcpClient
Dim server As String = txtserver.Text
Dim porta As Int32 = txtporta.Text
Dim message As String = txtsend.text
Dim send As [Byte]() = System.Text.Encoding.ASCII.GetBytes(message)
Dim stream As NetworkStream = client.GetStream()

Public Sub New()
Me.InitializeComponent()
End Sub

Sub Button1Click(ByVal sender As Object, ByVal e As EventArgs)
If button1.Text = "Connetti" Then
button1.Text = "Disconnetti"
client.Connect(server, porta)
Else
button1.Text = "Connetti"
stream.Close()
client.Close()
End If
End Sub
Sub Button2Click(ByVal sender As Object, ByVal e As EventArgs)

End Sub
End Class

Uso un IDE SharpDevelop 2.2