Support Forums
VB - Chat program - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Visual Basic and the .NET Framework (https://www.supportforums.net/forumdisplay.php?fid=19)
+---- Thread: VB - Chat program (/showthread.php?tid=13553)

Pages: 1 2 3


VB - Chat program - eax - 11-08-2010

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



RE: VB - Chat program - Shane - 11-08-2010

Nice Program Good Work!


RE: VB - Chat program - Resistance - 11-08-2010

Smart and Crafty... I like it! Thanks for the application!


RE: VB - Chat program - Statics - 11-09-2010

Can't believe it!

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

LOVE IT!


RE: VB - Chat program - eax - 11-09-2010

(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. (:


RE: VB - Chat program - Jet - 11-11-2010

So basically you connect to someone's ip that has this program, and you can talk to each other?


RE: VB - Chat program - eax - 11-13-2010

(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.


RE: VB - Chat program - SYNTAX ERR0R - 11-13-2010

GUI is a little basic, but that's nothing that can't be easily sorted. VERY nice work amigo.


RE: VB - Chat program - eax - 11-13-2010

Yeah it is. It was only to show how it works. I wasn't actually using it for anything.


RE: VB - Chat program - SYNTAX ERR0R - 11-13-2010

(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 .