Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit On
- Imports System.IO
- Imports System.Net.Sockets
- Imports System.Net
- Public Class Form1
- Dim Client As TcpClient
- Dim Listener As New TcpListener(8000)
- Dim Client2 As TcpClient
- Private Sub _FormClosing() Handles Me.FormClosing
- Listener.Stop()
- End Sub
- Private Sub _Load() Handles MyBase.Load
- Timer2.Start()
- Listener.Start()
- End Sub
- Private Sub _Tick() Handles Timer1.Tick
- txtNick.Hide()
- Dim Message As String
- Dim nStart As Integer
- Dim nLast As Integer
- If Listener.Pending = True Then
- Message = ""
- Client = Listener.AcceptTcpClient()
- Dim Reader As New StreamReader(Client.GetStream())
- While Reader.Peek > -1
- Message &= Convert.ToChar(Reader.Read()).ToString
- End While
- If Message.Contains("</>") Then
- nStart = InStr(Message, "</>") + 4
- nLast = InStr(Message, "<\>")
- Message = Mid(Message, nStart, nLast - nStart)
- End If
- RichTextBox1.AppendText(Message & vbNewLine)
- End If
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs)
- End Sub
- Private Sub Button3_Click(sender As System.Object, e As System.EventArgs)
- Me.ComboBox1.Items.AddRange(Dns.GetHostAddresses(GetComputerName))
- End Sub
- Private Function GetComputerName() As String
- Return Dns.GetHostName
- End Function
- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- Timer1.Start()
- Dim r As Rectangle
- If Parent IsNot Nothing Then
- r = Parent.RectangleToScreen(Parent.ClientRectangle)
- Else
- r = Screen.FromPoint(Me.Location).WorkingArea
- End If
- Dim x = r.Left + (r.Width - Me.Width) \ 2
- Dim y = r.Top + (r.Height - Me.Height) \ 2
- Me.Location = New Point(x, y)
- Me.ComboBox1.Items.AddRange(Dns.GetHostAddresses(GetComputerName))
- Label8.Hide()
- Dim myIPaddress As String
- Dim tmpHostName As String = System.Net.Dns.GetHostName()
- myIPaddress = System.Net.Dns.GetHostByName(tmpHostName).AddressList(0).ToString()
- txtNick.Text = myIPaddress
- End Sub
- Private Sub Button2_Click_1(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- Application.Exit()
- End Sub
- Private Sub btnClick(sender As System.Object, e As System.EventArgs)
- End Sub
- Private Sub PictureBox2_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox2.Click
- Dim Person As String
- Person = ComboBox1.Text
- Try
- Client = New TcpClient(Person, 8000)
- Dim Writer As New StreamWriter(Client.GetStream())
- Writer.Write("</> " & TextBox1.Text & " -From " & txtNickname.Text & " (" & txtNick.Text & ")" & " at " & Label8.Text & " <\>")
- Writer.Flush()
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- If ComboBox1.Text = Nothing Then
- MsgBox("Please Enter an IP To Recieve Your Message", MsgBoxStyle.Critical)
- End If
- Me.Text = "IPv4 Messanger (Messaging: " & ComboBox1.Text & " as " & txtNick.Text & ")"
- ListBox1.Items.Add(ComboBox1.Text)
- End Sub
- Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
- End Sub
- Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
- If e.KeyCode = Keys.Enter Then
- Dim Person As String
- Person = ComboBox1.Text
- Try
- Client = New TcpClient(Person, 8000)
- Dim Writer As New StreamWriter(Client.GetStream())
- Writer.Write("</> " & TextBox1.Text & " -From " & txtNickname.Text & " (" & txtNick.Text & ")" & " at " & Label8.Text & " <\>")
- Writer.Flush()
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- ListBox1.Items.Add(ComboBox1.Text)
- End If
- Me.Text = "IPv4 Messanger (Messaging: " & ComboBox1.Text & " as " & txtNick.Text & ")"
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- TextBox1.Clear()
- End Sub
- Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
- Label8.Text = Format(Now, "hh:mm tt")
- End Sub
- Private Sub ExitToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ExitToolStripMenuItem.Click
- Application.Exit()
- End Sub
- Private Sub Button3_Click_1(sender As System.Object, e As System.EventArgs) Handles Button3.Click
- ListBox1.Items.Clear()
- End Sub
- Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
- End Sub
- Private Sub txtNick_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNick.TextChanged
- End Sub
- Private Sub Label9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.Click
- End Sub
- Private Sub InfoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoToolStripMenuItem.Click
- MsgBox("IPv4 Messanger uses a system of networking called TCP to send messages from one IPv4 address to another as long as they are on the same WiFi", MsgBoxStyle.Information)
- End Sub
- Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
- RichTextBox1.Clear()
- End Sub
- Private Sub RedToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles RedToolStripMenuItem.Click
- RichTextBox1.ForeColor = Color.Red
- RichTextBox1.BackColor = Color.White
- TextBox1.BackColor = Color.White
- TextBox1.ForeColor = Color.Black
- End Sub
- Private Sub BlackToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles BlackToolStripMenuItem.Click
- RichTextBox1.ForeColor = Color.Black
- RichTextBox1.BackColor = Color.White
- TextBox1.BackColor = Color.White
- TextBox1.ForeColor = Color.Black
- End Sub
- Private Sub PinkToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles PinkToolStripMenuItem.Click
- RichTextBox1.ForeColor = Color.Violet
- RichTextBox1.BackColor = Color.White
- TextBox1.BackColor = Color.White
- TextBox1.ForeColor = Color.Black
- End Sub
- Private Sub BlueToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles BlueToolStripMenuItem.Click
- RichTextBox1.ForeColor = Color.Blue
- RichTextBox1.BackColor = Color.White
- TextBox1.BackColor = Color.White
- TextBox1.ForeColor = Color.Black
- End Sub
- Private Sub LimeToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles LimeToolStripMenuItem.Click
- RichTextBox1.ForeColor = Color.Green
- TextBox1.BackColor = Color.White
- TextBox1.ForeColor = Color.Black
- RichTextBox1.BackColor = Color.White
- End Sub
- Private Sub H4X0RToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles H4X0RToolStripMenuItem.Click
- RichTextBox1.ForeColor = Color.Lime
- RichTextBox1.BackColor = Color.Black
- TextBox1.BackColor = Color.Black
- TextBox1.ForeColor = Color.Lime
- End Sub
- Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
- End Sub
- Private Sub Label8_Click(sender As System.Object, e As System.EventArgs) Handles Label8.Click
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement