Link to home
Start Free TrialLog in
Avatar of forrest321
forrest321

asked on

Fluent.Toc VB.NET AOL/AIM Programming question

I am attempting to use the .NET component found here: http://www.fluentconsulting.com/components/Fluent.Toc/

I have never used delegates before, and could use some help.  I do not know how to get an event handler set up to handle incoming aol messages.

Their snippet for this is as follows:

TocClient tc = new TocClient();
tc.Message += new MessageEventHandler(OnMessage);
tc.SignOn("myscreenname","password");
tc.StartListening();
...
protected void  OnMessage(object sender, MessageEventArgs e){
  WriteLine("{0}: {1}",e.From, e.Message);
}

I assume this is a console C# app.  

The code for my VB.NET Windows App:

Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim tc As New Fluent.Toc.TocClient
    Dim msHan As New Fluent.Toc.MessageEventHandler(AddressOf msgHandler)
*WINDOWS FORM DESIGNER generated code*

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tc.SignOn("MyUserName", "MyPassword")
        tc.StartListening()
        TextBox1.Text = tc.Connected
    End Sub
    Private Sub msgHandler(ByVal sender As Object, ByVal e As Fluent.Toc.MessageEventArgs)
        MsgBox("from: " & e.From & vbCrLf & "message: " & e.Message)
    End Sub
End Class

Can anyone see what I have wrong?

Thanks
Avatar of forrest321
forrest321

ASKER

Just doubled the points for this question!  I need help on this one bad!
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim tc As New Fluent.Toc.TocClient
    Dim msHan As Fluent.Toc.MessageEventHandler

*WINDOWS FORM DESIGNER generated code*

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
   tc.Message += new MessageEventHandler(OnMessage);
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tc.SignOn("MyUserName", "MyPassword")
        tc.StartListening()
        TextBox1.Text = tc.Connected
    End Sub
    Private Sub msgHandler(ByVal sender As Object, ByVal e As Fluent.Toc.MessageEventArgs)
        MsgBox("from: " & e.From & vbCrLf & "message: " & e.Message)
    End Sub
End Class


ASKER CERTIFIED SOLUTION
Avatar of gillgates
gillgates

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!

Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim tc As Fluent.Toc.TocClient
    'Dim msHan As Fluent.Toc.MessageEventHandler - not needed

*WINDOWS FORM DESIGNER generated code*

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tc = New Fluent.Toc.TocClient  
AddHandler tc.Message, AddressOf msgHandler
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tc.SignOn("MyUserName", "MyPassword")
        tc.StartListening()
        TextBox1.Text = tc.Connected
    End Sub
    Private Sub msgHandler(ByVal sender As Object, ByVal e As Fluent.Toc.MessageEventArgs)
        MsgBox("from: " & e.From & vbCrLf & "message: " & e.Message)
    End Sub
End Class