Solved

convert c to vb.net please

Posted on 2006-11-11
5
315 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now