Pls help with Raising Events in my own classes

I have read the AddHandler and Class docs over and over and I am not getting it.

I am creating a class that wraps up FTP functionality in a 3rd party plugin (ChilKat). The FTP side works just fine.

I instantiate my class in my main code and make calls to the class to process files for upload.

I want to create events in my class and be able to use those events in my main code to flag start/end of uploads etc.

In my class (clsFTP) I have created 2 Event Definitions “PreStart” and “PostStart”

In my Main code I have this code to create my FTP object based on the class and for each event I want to use in the base class

Var FTP as New clsFTP
AddHandler FTP.PreSend Addressof FileUploadStarted
AddHandler FTP.PostSend AddressOf FileUploadCompleted

And finally in my main code I have 2 methods,

FileUploadStarted (Sender as clsFTP)
FileUploadCompleted (Sender as clsFTP)

When I compile I get this error

winDataUpload.ProcessPictures, line 14
Type “clsFTP” has no member named “PreSend”
AddHandler FTP.PreSend Addressof FileUploadStarted

Same error for the other event.

I have read and re-read the Addhandler docs but just cant see what I’m doing wrong.

Pls help!!! :slight_smile:

Unless that’s a copy/paste error here, I wonder if it’s the missing comma after the event name?

AddHandler FTP.PreSend, Addressof FileUploadStarted



Thank you!

I have stared at that for hours and didnt spot it.

Life saver :slight_smile:

1 Like