• Welcome to Valhalla Legends Archive.
 

[VB] 1st Error -- Making an IRC Client

Started by Alendar, March 03, 2008, 08:51 PM

Previous topic - Next topic

Alendar

So I am slowly learning VB.NET and I am starting with making my own IRC client.

Right now I am getting this error:

QuoteError 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

From this line:

Private Sub wsIRC_ConnectEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles modDeclares.tpcIRC.ConnectEvent

Here is the the part where I declare the tpcIRC:

Public WithEvents tpcIRC As System.Net.Sockets.TcpClient

Thank you for any assistants. As I said, I am new to VB.NET so if you have any tips for me they will be greatly appreciated.

Alendar

- Joseph W
http://josephw.net


Joe[x86]

Why is tcpIRC in modDeclares?

Other than that, I'm not sure. I don't know understand the syntax of VB.NET's events. If I really wanted to I could reverse some of my code with .NET Reflector, but I'm too lazy for now since someone else can probably help you.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Alendar

Quote from: Joex86] link=topic=17365.msg176784#msg176784 date=1204604391]
Why is tcpIRC in modDeclares?

Other than that, I'm not sure. I don't know understand the syntax of VB.NET's events. If I really wanted to I could reverse some of my code with .NET Reflector, but I'm too lazy for now since someone else can probably help you.

That's just where I placed it. >_>
- Joseph W
http://josephw.net


MyndFyre

Well, System.Net.Sockets.TcpClient doesn't have a ConnectEvent event.  In fact, it doesn't have ANY events.  So, even with a WithEvents declaration, you're not going to be able to hook into the events.  Because there aren't any.

RTFM.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Imperceptus

I am working on my own IRC client at the moment.  I am just using the socket class. not tcpclient.   So far so good with that part.  This should help get you going. http://perseus.franklins.net/dnrtv/0046/parta.html

Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

Alendar

- Joseph W
http://josephw.net


Imperceptus

Always good to share your solution, so future people that may come across this thread by searching may learn from it as well.
Quote from: Hazard on August 07, 2003, 03:15 PM
Highlight your entire code. Press the delete key. Start over again using Cuphead's CSB tutorial and work your way from their rather than raping code from downloaded sources meant purely for learning purposes. If this does not fix the problem, uninstall Visual Basic and get a new hobby. I suggest Cricket.

Alendar

I decided to go with a WinSock object and found out placing the Sub into the form helps. :p
- Joseph W
http://josephw.net


UserLoser

#8
sorry but i must nudge in here cause this is why this forum goes to shit:

Quote from: Joex86] link=topic=17365.msg176784#msg176784 date=1204604391]
Why is tcpIRC in modDeclares?

Other than that, I'm not sure. I don't know understand the syntax of VB.NET's events. If I really wanted to I could reverse some of my code with .NET Reflector, but I'm too lazy for now since someone else can probably help you.

useless post, if you're not sure/who cares where he declares stuff then why even say something especially if you're too lazy.

Quote from: MyndFyre[vL] on March 04, 2008, 10:24 PM
Well, System.Net.Sockets.TcpClient doesn't have a ConnectEvent event.  In fact, it doesn't have ANY events.  So, even with a WithEvents declaration, you're not going to be able to hook into the events.  Because there aren't any.

RTFM.

the whole point of a forum is to ask questions.  apparently he is new, everyone makes mistakes and not everyone comprehends new terminology right away.  i never learned from reading the manual i was all hands on figuring out things my self here and there.

just voicing whats on my mind, but i liked when you were new here and used to ask how to send packets to b.net but now you boss everyone around like a dick or everyone should praise you ::)

MyndFyre

Quote from: UserLoser on March 06, 2008, 04:50 AM
the whole point of a forum is to ask questions.  apparently he is new, everyone makes mistakes and not everyone comprehends new terminology right away.  i never learned from reading the manual i was all hands on figuring out things my self here and there.

just voicing whats on my mind, but i liked when you were new here and used to ask how to send packets to b.net but now you boss everyone around like a dick or everyone should praise you ::)
There's a difference between cobbling together source code that I didn't write and asking someone to explain to me why it doesn't work when it's already well-documented (which I never did) and asking about possibly obscure documentation in terms that don't jibe with what you're doing.  It's funny, because a Google search for the word "TcpClient" (nothing too terribly hard about figuring this one out) gives the documentation link as the first result.  Even when I was new I understood how to look up documentation.

It'd be one thing if he came in and said "I don't understand what a DWORD is in Visual Basic" - there's NO commonality between the Bnet data types and Visual Basic types (at least in terms of the name).  But, if you look at his source, it's clear he's got a couple different sources of code:


Handles modDeclares.tpcIRC.ConnectEvent

modDeclares - it's clear this code is inspired by VB6.  VB.net modules don't require you to reference the module name in order to qualify the reference to the module variable.  Also, since VB.net has classes, there's not need to separate out things into a "declares" module - classes should contain the objects that they control.

Next: WithEvents/Handles -- Joe was actually correct in this case:
Quote from: UserLoser on March 06, 2008, 04:50 AM
Quote from: Joex86] link=topic=17365.msg176784#msg176784 date=1204604391]
Why is tcpIRC in modDeclares?

Other than that, I'm not sure. I don't know understand the syntax of VB.NET's events. If I really wanted to I could reverse some of my code with .NET Reflector, but I'm too lazy for now since someone else can probably help you.
useless post, if you're not sure/who cares where he declares stuff then why even say something especially if you're too lazy.
WithEvents variables are only valid in the same class/type scope in which they are declared.  So, he can't just "Handles" events that are fired by an object in another class - he has to use the AddHandler/RemoveHandler semantics to get the desired behavior out of the other class, or do the preferred way and bring the variable into the class that wants to handle his events.  If he had, he would have gotten a more helpful compiler error:

error BC30590: Event 'ConnectEvent' cannot be found.


QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

Er... VB6 doesn't require you to use the module name either; I think it was for clarity.