Imports Microsoft.VisualBasic
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading
Imports System.Text
Imports System.IO.FileNotFoundException
Imports System.IO.Stream
Imports System.Windows.Forms
Public Class Form2
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.Button3 = New System.Windows.Forms.Button
Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
Me.PictureBox1 = New System.Windows.Forms.PictureBox
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(98, 73)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(330, 78)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = " "
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(12, 76)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(48, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "ข้อความ"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(12, 43)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(80, 24)
Me.Label2.TabIndex = 2
Me.Label2.Text = "เรียกใช้ IP"
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(98, 43)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(136, 20)
Me.TextBox2.TabIndex = 3
Me.TextBox2.Text = "192.168.200.251"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(3, 233)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(89, 24)
Me.Label3.TabIndex = 4
Me.Label3.Text = "ข้อความสนทนา"
'
'TextBox3
'
Me.TextBox3.Location = New System.Drawing.Point(98, 258)
Me.TextBox3.Multiline = True
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(330, 124)
Me.TextBox3.TabIndex = 5
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(434, 197)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(70, 24)
Me.Button1.TabIndex = 6
Me.Button1.Text = "ส่ง"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(434, 160)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(70, 24)
Me.Button2.TabIndex = 6
Me.Button2.Text = "เลือกไฟล์"
'
'OpenFileDialog1
'
Me.OpenFileDialog1.FileName = "OpenFileDialog1"
'
'TextBox4
'
Me.TextBox4.Location = New System.Drawing.Point(98, 160)
Me.TextBox4.Multiline = True
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(330, 24)
Me.TextBox4.TabIndex = 7
'
'TextBox5
'
Me.TextBox5.Location = New System.Drawing.Point(98, 17)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(136, 20)
Me.TextBox5.TabIndex = 8
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(12, 13)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(80, 24)
Me.Label4.TabIndex = 9
Me.Label4.Text = "ชื่อผู้ส่ง"
'
'TextBox6
'
Me.TextBox6.Location = New System.Drawing.Point(98, 388)
Me.TextBox6.Multiline = True
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.Size = New System.Drawing.Size(330, 24)
Me.TextBox6.TabIndex = 10
'
'Button3
'
Me.Button3.Location = New System.Drawing.Point(434, 388)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(70, 24)
Me.Button3.TabIndex = 11
Me.Button3.Text = "บันทึกไฟล์"
'
'SaveFileDialog1
'
'
'PictureBox1
'
Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.PictureBox1.Image = Global.WindowsApplication1.My.Resources.Resources.Clip_2
Me.PictureBox1.Location = New System.Drawing.Point(434, 3)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(121, 119)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox1.TabIndex = 12
Me.PictureBox1.TabStop = False
'
'Form2
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(567, 495)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
Me.Name = "Form2"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bytes(200) As Byte
Dim MyIP As IPAddress
Dim RemoteIP As IPAddress
Dim str As String
RemoteIP = IPAddress.Parse(TextBox2.Text)
MyIP = IPAddress.Parse("192.168.200.251")
Dim Port1 As Integer = 8080
Dim port2 As Integer = 8081
Dim myLocal As New IPEndPoint(MyIP, Port1)
Dim myRemote As New IPEndPoint(RemoteIP, port2)
Dim receive1 As New UdpClient(myRemote)
Dim send1 As New UdpClient(myLocal)
Try
bytes = System.Text.Encoding.UTF8.GetBytes(TextBox1.Text.ToUpper)
send1.Send(bytes, bytes.Length, myRemote)
str = System.Text.Encoding.UTF8.GetString(bytes)
TextBox3.Text = TextBox3.Text & vbCrLf & str
bytes = receive1.Receive(myLocal)
str = System.Text.Encoding.UTF8.GetString(bytes)
TextBox3.Text = TextBox2.Text & " : " & TextBox5.Text & vbCrLf & str
TextBox6.Text = TextBox4.Text
Catch ex As Exception
Console.WriteLine("")
End Try
send1.Close()
receive1.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.Filter = " All files (*.*)|*.*"
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
TextBox4.Text = OpenFileDialog1.FileName
End If
End Sub
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
End Sub
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
Private WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub PictureBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDoubleClick
OpenFileDialog1.Filter = " All files (*.*)|*.*"
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.ImageLocation = OpenFileDialog1.FileName
End If
End Sub
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
SaveFileDialog1.Filter = " All files (*.*)|*.*"
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
TextBox6.Text = SaveFileDialog1.FileName
End If
End Sub
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
End Sub
End Class