Thread Rating:
  • 3 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VB - Chat program
#1
Here is a simple chat program that uses IP's to talk to each other.
You can adapt it to work how you like;

[Image: 9ti9gx.jpg]


Code:
Imports VB = Microsoft.VisualBasic
Public Class frmChat
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
    Dim UserID As String

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        End
    End Sub

    Private Sub btnMySend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMySend.Click
        Dim Message As String
        Message = "[" & UserID & "] " & txtMySend.Text

        AxWinsock1.RemoteHost = AxWinsock1.LocalIP
        AxWinsock1.SendData(Of Date)()
        If AxWinsock1.LocalIP = txtIPAddress.Text Then
            AxWinsock1.RemoteHost = txtIPAddress.Text
            AxWinsock1.SendData(Message)
        End If
        txtMySend.Text = ""
        txtMySend.Focus()
    End Sub

    Private Sub frmChat_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AxWinsock1.Protocol = MSWinsockLib.ProtocolConstants.sckTCPProtocol
        AxWinsock1.RemoteHost = AxWinsock1.LocalIP
        AxWinsock1.RemotePort = 10
        AxWinsock1.LocalPort = 11

        Dim sBuffer As String
        Dim lSize As Integer
        sBuffer = Space(255)
        lSize = Len(sBuffer)
        Call GetUserName(sBuffer, lSize)
        If lSize > 0 Then
            UserID = VB.Left(sBuffer, lSize - 1)
        Else
            UserID = vbNullString
        End If
        Me.Text = Me.Text + UserID & " at " & AxWinsock1.LocalIP
        txtIPAddress.Text = AxWinsock1.LocalIP
        txtMyIP.Text = AxWinsock1.LocalIP
    End Sub

    Private Sub AxWinsock1_DataArrival(ByVal sender As Object, ByVal e As AxMSWinsockLib.DMSWinsockControlEvents_DataArrivalEvent) Handles AxWinsock1.DataArrival
        Dim Arrival As String = ""
        AxWinsock1.GetData(Arrival)
        txtMyArrival.Text = txtMyArrival.Text & Arrival & vbNewLine
    End Sub
    Private Sub txtIPAddress_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIPAddress.Leave
        AxWinsock1.RemoteHost = txtIPAddress.Text
    End Sub
End Class
Someone with no history is nothing but suspicious.
Reply
#2
Nice Program Good Work!
Reply
#3
Smart and Crafty... I like it! Thanks for the application!
[Image: t5BWm.png]
Reply
#4
Can't believe it!

I did not know there was a simple program such as this that does these kind of things!

LOVE IT!
Reply
#5
(11-09-2010, 01:34 PM)Currymanz Wrote: Can't believe it!

I did not know there was a simple program such as this that does these kind of things!

LOVE IT!

If there's anything else you require just ask. I'll do the best I can. (:
Someone with no history is nothing but suspicious.
Reply
#6
So basically you connect to someone's ip that has this program, and you can talk to each other?
Reply
#7
(11-11-2010, 05:54 PM)Jet Wrote: So basically you connect to someone's ip that has this program, and you can talk to each other?

That's correct.
Someone with no history is nothing but suspicious.
Reply
#8
GUI is a little basic, but that's nothing that can't be easily sorted. VERY nice work amigo.
Reply
#9
Yeah it is. It was only to show how it works. I wasn't actually using it for anything.
Someone with no history is nothing but suspicious.
Reply
#10
(11-13-2010, 01:57 PM)Ameise Wrote: Yeah it is. It was only to show how it works. I wasn't actually using it for anything.

Well I really like it, and it is something I will use Thumbsup. I will have to wait until I get comp out of safe mode though as it won't let me download VB Sad .
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  IP Chat Program SOURCE kpn37z 1 1,428 12-08-2012, 07:41 PM
Last Post: Pro-A-Blazed
  Help with a part of chat program... Danny 7 1,412 05-18-2010, 09:27 AM
Last Post: //Pretextâ„¢

Forum Jump:


Users browsing this thread: 2 Guest(s)