Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

convert c to vb.net please

Posted on 2006-11-11
5
Medium Priority
?
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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