473,788 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help defining an event handler...

I'm running Visual Basic Express Editon 2008.
I have a project that references an OLE object called MyObject
That object fires events.
How do I declare the event handler in the Main Form class
implementation?

Public Class Form1

Dim WithEvents server as MyObject.MyServ er

? How do I declare the event handler?

End Class

I was told that it should be in the IDE but I don't see anything that
would help me declare this method in my code.
Nov 20 '08 #1
4 1687
On Nov 20, 7:45*pm, SpreadTooThin <bjobrie...@gma il.comwrote:
I'm running Visual Basic Express Editon 2008.
I have a project that references an OLE object called MyObject
That object fires events.
How do I declare the event handler in the Main Form class
implementation?

Public Class Form1

* *Dim WithEvents server as MyObject.MyServ er

? *How do I declare the event handler?

End Class

I was told that it should be in the IDE but I don't see anything that
would help me declare this method in my code.
As you're using a form, you can also subscribe its events in your
Form1.Designer. vb partial class like:
Friend WithEvents server As MyObject.MyServ er

To handle, use Handles clause:
Like that:
Public Class Form1

' In your form
' Assuming it has a click method
Private Sub MyServer_Click( ByVal sender As Object, _
ByVal e As System.EventArg s) Handles MyServer.Click

End Class
....of course i cannot test it as the object is custom (not included in
framework, thus we don't know what events and signatures it expose),
but hope that gives some idea.

Hope this helps,

Onur Güzel
Nov 20 '08 #2

"SpreadTooT hin" <bj********@gma il.comwrote in message
news:c2******** *************** ***********@k36 g2000pri.google groups.com...
I'm running Visual Basic Express Editon 2008.
I have a project that references an OLE object called MyObject
That object fires events.
How do I declare the event handler in the Main Form class
implementation?

Public Class Form1

Dim WithEvents server as MyObject.MyServ er

? How do I declare the event handler?

End Class

I was told that it should be in the IDE but I don't see anything that
would help me declare this method in my code.

Ok:

1. Open form with the OLE object in the designer
2. Select the object on the form
3. Go to properties (F4)
4. In the properties window click the lightning bolt at on the properties
window toolbar
5. You should now see a list of all the events which the dot.net
framework knows about for the object
6. Double click in the dropdown box to the right of the Event name

This should create a stub for you in your code.

LS

Nov 20 '08 #3

"Lloyd Sheen" <a@b.cwrote in message
news:Ot******** ******@TK2MSFTN GP06.phx.gbl...
>
1. Open form with the OLE object in the designer
2. Select the object on the form
3. Go to properties (F4)
4. In the properties window click the lightning bolt at on the
properties window toolbar
5. You should now see a list of all the events which the dot.net
framework knows about for the object
6. Double click in the dropdown box to the right of the Event name

This should create a stub for you in your code.
But that just handles simple, built-in events. I think that the OP wanted a
custom event that could be picked up by other forms/objects.

JW

Nov 21 '08 #4

"John Whitworth" <sexyjw@g_eeeee eeeeeeee_mail.c omwrote in message
news:CB******** *************** ***********@mic rosoft.com...
>
"Lloyd Sheen" <a@b.cwrote in message
news:Ot******** ******@TK2MSFTN GP06.phx.gbl...
>>
1. Open form with the OLE object in the designer
2. Select the object on the form
3. Go to properties (F4)
4. In the properties window click the lightning bolt at on the
properties window toolbar
5. You should now see a list of all the events which the dot.net
framework knows about for the object
6. Double click in the dropdown box to the right of the Event name

This should create a stub for you in your code.

But that just handles simple, built-in events. I think that the OP wanted
a custom event that could be picked up by other forms/objects.

JW
An event is an event. There are no custom events just events. If an object
on a form has PUBLIC events they will show in the list unless there is an
attribute (don't know what it is offhand) that will stop the event from
showing in the list.

The OLE object dropped on the form has to be of a type that exposes the
event.

LS

Nov 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4222
by: Srinath Avadhanula | last post by:
Hello, I am wondering if QT has something like QWaitForNextEvent() function. This function would block execution of the application till another key was pressed and then return the event which occured. Would like to utlize this in a small application I am building: I am trying to create vi key-bindings for a simple QMultiLineEdit
8
2035
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to get the focus no matter where on the page the user clicks be it right-click or left-click. Right now there is no context menu when the user right-clicks. Do you think that's the problem? Any ideas how to get this right-click left-click Input box...
1
2041
by: 0to60 | last post by:
More importantly, WHY do I wanna do this? Well, I have events that I raise asynchronously like this: foreach(eventhandler handler in eventname.getinvocationlist()) handler.begininvoke(); Now, I'd like to put a callback in there so I can call endinvoke and catch any exceptions that get thrown in event handling code. Now, to call endinvoke, you have to save the IAsynchResult returned by begininvoke, and
1
1461
by: lawrence | last post by:
I'm trying to gain a better understanding of javascript by studying examples. I noticed this in an online tutorial. I don't get the use of "this". >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You might want to add some event handler for an event to an element to which there is already an event handler attached. That is possible by storing the old event handler somewhere and then writing a new function which calls the old event handler.
106
6477
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as dao.recordset
17
2677
by: Hazz | last post by:
In this sample code of ownerdraw drawmode, why does the '(ComboBox) sender' line of code need to be there in this event handler? Isn't cboFont passed via the managed heap, not the stack, into this cboFont_DrawItem event handler? Why does it need to be cast? -hazz ,................. cboFont.Items.AddRange(FontFamily.Families); } private void cboFont_DrawItem(object sender,
3
1970
by: Beth | last post by:
in the following: this.ExitButton.Click += new System.EventHandler(this.ExitButton_Click); if I saw an equation, such as y +=x; then y = y+x. But what is the meaning in the event handler. I realize it is adding an event handler for the click event of the exit button, but how do i reason through the 2 step process inferred by the += equation.
5
3611
by: Charles Bazi | last post by:
Hi, I have a base UserControl named UserControlEx. I have created an event, and a dummy handler. Then I create several UCs with UserControlEx base. Some of those have a handler for my custom event, others, no... I manage to have the list of events with EventInfo, but I'm unable to see if some event has a handler associated...
10
2847
by: Peter Michaux | last post by:
Hi, Today I have been testing the event models from Netscape 4.8 and IE 4 to the current crop of browsers. I'd like to write a small event library similar in purpose to the Yahoo! UI event library but with less features and code. The Yahoo! event library is one of the best libraries in YUI but it still seems to me to have some confused code...that or I'm still confused. The Yahoo! UI library focuses on using addEventListener and
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10112
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.