Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

convert c to vb.net please

Posted on 2006-11-11
5
Medium Priority
?
339 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 2000 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 86

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 86

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

971 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