Solved

convert c to vb.net please

Posted on 2006-11-11
5
328 Views
Last Modified: 2008-02-01
i have the dll loaded into vb.net
upon pasteing this most things work like the irc. calls
with
public irc = new ircclient  

im havng problems converting this to vb.net 2005 (can someone help me out im not sure how to do the threading part too
thanks
****************************

  public static void Main(string[] args)
    {
        Thread.CurrentThread.Name = "Main";
        irc.SendDelay = 400;
        irc.ActiveChannelSyncing = true;
       
        irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage);
        irc.OnError += new ErrorEventHandler(OnError);
        irc.OnRawMessage += new IrcEventHandler(OnRawMessage);

        string[] serverlist;
        // the server we want to connect to, could be also a simple string
        serverlist = new string[] {"irc.dragonirc.com"};
        int port = 6667;
      string channel = "#OCS";
        try {
            irc.Connect(serverlist, port);
        } catch (ConnectionException e) {
            System.Console.WriteLine("couldn't connect! Reason: "+e.Message);
            Exit();
        }
       
        try {
            irc.Login("SmartIRC", "SmartIrc4net Test Bot");
            irc.RfcJoin(channel);
            new Thread(new ThreadStart(ReadCommands)).Start();
            irc.Listen();
            irc.Disconnect();
        } catch (ConnectionException) {
            Exit();
        } catch (Exception e) {
            System.Console.WriteLine("Error occurred! Message: "+e.Message);
            System.Console.WriteLine("Exception: "+e.StackTrace);
            Exit();
        }
    }
   
0
Comment
Question by:Johnny
  • 2
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
newyuppie earned 500 total points
ID: 17923007
Public Shared Sub Main(ByVal args As String())
 Thread.CurrentThread.Name = "Main"
 irc.SendDelay = 400
 irc.ActiveChannelSyncing = True
 irc.OnQueryMessage += New IrcEventHandler(OnQueryMessage)
 irc.OnError += New ErrorEventHandler(OnError)
 irc.OnRawMessage += New IrcEventHandler(OnRawMessage)
 Dim serverlist As String()
 serverlist = New String() {"irc.dragonirc.com"}
 Dim port As Integer = 6667
 Dim channel As String = "#OCS"
 Try
   irc.Connect(serverlist, port)
 Catch e As ConnectionException
   System.Console.WriteLine("couldn't connect! Reason: " + e.Message)
   Exit
 End Try
 Try
   irc.Login("SmartIRC", "SmartIrc4net Test Bot")
   irc.RfcJoin(channel)
   call (New Thread(New ThreadStart(ReadCommands))).Start
   irc.Listen
   irc.Disconnect
 Catch generatedExceptionVariable0 As ConnectionException
   Exit
 Catch e As Exception
   System.Console.WriteLine("Error occurred! Message: " + e.Message)
   System.Console.WriteLine("Exception: " + e.StackTrace)
   Exit
 End Try
End Sub
0
 
LVL 13

Expert Comment

by:newyuppie
ID: 17923010
use http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx 
to convert yourself, for future reference. i think its the best free converter...
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17923742
These lines:

        irc.OnQueryMessage += new IrcEventHandler(OnQueryMessage);
        irc.OnError += new ErrorEventHandler(OnError);
        irc.OnRawMessage += new IrcEventHandler(OnRawMessage);

are wiring up event handlers.

They equivalent in VB should be:

        AddHandler irc.OnQueryMessage, AddressOf OnQueryMessage
        AddHandler irc.OnError, AddressOf OnError
        AddHandler irc.OnRawMessage, AddressOf OnRawMessage



Then you will also need to use "AddressOf" when you create your Thread:

    Call (New Thread(AddressOf ReadCommands)).Start
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17924031
Did that code actually work???...
0
 

Author Comment

by:Johnny
ID: 17926638
Error      14      'OnQueryMessage' is not an event of 'Object'.      E:\Projects\ircd stress\ircd stress\Module2.vb      63      24      ircd stress
Error      15      'OnError' is not an event of 'Object'.      E:\Projects\ircd stress\ircd stress\Module2.vb      64      24      ircd stress
Error      16      'OnRawMessage' is not an event of 'Object'.      E:\Projects\ircd stress\ircd stress\Module2.vb      65      24      ircd stress

trying your additions idlemind gives
i didnt see your comments i opened a new question

http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_22057927.html

id love to get this all to work...that be great!!

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question