Solved

convert c to vb.net please

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

813 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

14 Experts available now in Live!

Get 1:1 Help Now