473,408 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Can this be converted into a simple class

Hi

Could someone give me pointers on how to change this code (belwo) into a
simple class?

Thanks

Regards

Imports System

Imports System.Reflection

Imports System.Runtime.InteropServices

<Assembly: AssemblyKeyFile("C:\EventHelper.snk")>

Namespace IV.EventHelper

Public Interface IEventHelper

Event WordDocSaved(ByRef Doc As Object)

Event WordDocPrinted(ByRef Doc As Object)

Function Instance() As IEventHelper

Sub RaiseWordDocSaved(ByRef Doc As Object)

Sub RaiseWordDocPrinted(ByRef Doc As Object)

End Interface

<ClassInterface(ClassInterfaceType.None)> _

Public Class EventHelper

Implements IEventHelper

Public Event WordDocSaved(ByRef Doc As Object) Implements
IEventHelper.WordDocSaved

Public Event WordDocPrinted(ByRef Doc As Object) Implements
IEventHelper.WordDocPrinted

Private Shared _Instance As EventHelper

Public Function Instance() As IEventHelper Implements IEventHelper.Instance

If (_Instance Is Nothing) Then

SyncLock GetType(EventHelper)

If (_Instance Is Nothing) Then

_Instance = New EventHelper

End If

End SyncLock

End If

Return _Instance

End Function

Public Sub RaiseWordDocSaved(ByRef Doc As Object) Implements
IEventHelper.RaiseWordDocSaved

RaiseEvent WordDocSaved(Doc)

End Sub

Public Sub RaiseWordDocPrinted(ByRef Doc As Object) Implements
IEventHelper.RaiseWordDocPrinted

RaiseEvent WordDocPrinted(Doc)

End Sub

End Class

End Namespace
Nov 20 '05 #1
8 1370
John,
You have a simple class EventHelper and a simple interface IEventHelper.

How would you expect it to be any simpler?

Hope this helps
Jay

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi

Could someone give me pointers on how to change this code (belwo) into a
simple class?

Thanks

Regards

Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices

<Assembly: AssemblyKeyFile("C:\EventHelper.snk")>

Namespace IV.EventHelper

Public Interface IEventHelper

Event WordDocSaved(ByRef Doc As Object)

Event WordDocPrinted(ByRef Doc As Object)

Function Instance() As IEventHelper

Sub RaiseWordDocSaved(ByRef Doc As Object)

Sub RaiseWordDocPrinted(ByRef Doc As Object)

End Interface

<ClassInterface(ClassInterfaceType.None)> _

Public Class EventHelper

Implements IEventHelper

Public Event WordDocSaved(ByRef Doc As Object) Implements
IEventHelper.WordDocSaved

Public Event WordDocPrinted(ByRef Doc As Object) Implements
IEventHelper.WordDocPrinted

Private Shared _Instance As EventHelper

Public Function Instance() As IEventHelper Implements IEventHelper.Instance
If (_Instance Is Nothing) Then

SyncLock GetType(EventHelper)

If (_Instance Is Nothing) Then

_Instance = New EventHelper

End If

End SyncLock

End If

Return _Instance

End Function

Public Sub RaiseWordDocSaved(ByRef Doc As Object) Implements
IEventHelper.RaiseWordDocSaved

RaiseEvent WordDocSaved(Doc)

End Sub

Public Sub RaiseWordDocPrinted(ByRef Doc As Object) Implements
IEventHelper.RaiseWordDocPrinted

RaiseEvent WordDocPrinted(Doc)

End Sub

End Class

End Namespace

Nov 20 '05 #2
"John" <jo**@nospam.infovis.co.uk> schrieb

Could someone give me pointers on how to change this code (belwo)
into a simple class?
[...]


I copied the code. I don't know what's your intention, but it can be
compiled. So, what question do you have?
--
Armin

Nov 20 '05 #3
Instead of an assembly, I want to use this code as a class, in a separate
class file. What modifications do I need to make for this?

Thanks

Regards
"Armin Zingler" <az*******@freenet.de> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb

Could someone give me pointers on how to change this code (belwo)
into a simple class?
[...]


I copied the code. I don't know what's your intention, but it can be
compiled. So, what question do you have?
--
Armin

Nov 20 '05 #4
"John" <jo**@nospam.infovis.co.uk> schrieb
Could someone give me pointers on how to change this code
(belwo) into a simple class?
[...]


I copied the code. I don't know what's your intention, but it can
be compiled. So, what question do you have?


Instead of an assembly, I want to use this code as a class, in a
separate class file. What modifications do I need to make for
this?

Sorry, I still don't understand. I don't see the meaning of the term
"assembly" in this context. You can put the code in a separate file. Select
menu Project -> Add new item. In the dialog select the template "code file".
Then paste your code in the new file.

--
Armin

Nov 20 '05 #5
I am calling the previous code from another class as follows;

Public Class clsMyClass

Private WithEvents EH As EventHelper.IV.EventHelper.EventHelper ' <===
This line gives the error

...
...
End Class

But I am getting a 'c:\...\clsMyClass.vb(8): Type
'EventHelper.IV.EventHelper.EventHelper' is not defined.' error.

What changes do I need to make to make it work?

Thanks

Regards


"Armin Zingler" <az*******@freenet.de> wrote in message
news:OG**************@TK2MSFTNGP10.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb
> Could someone give me pointers on how to change this code
> (belwo) into a simple class?
> [...]

I copied the code. I don't know what's your intention, but it can
be compiled. So, what question do you have?
Instead of an assembly, I want to use this code as a class, in a
separate class file. What modifications do I need to make for
this?

Sorry, I still don't understand. I don't see the meaning of the term
"assembly" in this context. You can put the code in a separate file.

Select menu Project -> Add new item. In the dialog select the template "code file". Then paste your code in the new file.

--
Armin

Nov 20 '05 #6
"John" <jo**@nospam.infovis.co.uk> schrieb
I am calling the previous code from another class as follows;

Public Class clsMyClass

Private WithEvents EH As EventHelper.IV.EventHelper.EventHelper
' <===
This line gives the error

...
...
End Class

But I am getting a 'c:\...\clsMyClass.vb(8): Type
'EventHelper.IV.EventHelper.EventHelper' is not defined.' error.

What changes do I need to make to make it work?


What is the project's root namespace (see project properties)? Which
namespace contains class "clsMyClass"?
--
Armin

Nov 20 '05 #7
ContactsApp.vbproj

Regards

"Armin Zingler" <az*******@freenet.de> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
"John" <jo**@nospam.infovis.co.uk> schrieb
I am calling the previous code from another class as follows;

Public Class clsMyClass

Private WithEvents EH As EventHelper.IV.EventHelper.EventHelper
' <===
This line gives the error

...
...
End Class

But I am getting a 'c:\...\clsMyClass.vb(8): Type
'EventHelper.IV.EventHelper.EventHelper' is not defined.' error.

What changes do I need to make to make it work?


What is the project's root namespace (see project properties)? Which
namespace contains class "clsMyClass"?
--
Armin

Nov 20 '05 #8
"John" <jo**@nospam.infovis.co.uk> schrieb
ContactsApp.vbproj


This is the name of the project file, not the root namespace. However, both
are usually equal (without extension). Right-click on the project in the
solution explorer and select "properties". On the left side of the dialog
select General properties -> General. On the right there's a textbox
containing the root namespace.

If the root namespace is "ContactsApp", the variable "EH" must be declared
this way:

Private WithEvents EH As IV.EventHelper.EventHelper

You could also use the full qualified name

Private WithEvents EH As ContactsApp.IV.EventHelper.EventHelper

but this is not necessary because the namespace IV.Eventhalper and the class
clsMyClass are part of the same namespace.
--
Armin

Nov 20 '05 #9

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

Similar topics

2
by: Jim in Arizona | last post by:
I'm learning form an ASP.NET 1.0 book and I tried out some code that returns this error: Compiler Error Message: BC30311: Value of type 'Integer' cannot be converted to...
0
by: John | last post by:
I'm attempting to launch a converted window through the drop down menu in order to assess the functionality that the conversion wizard was able to preserve. However, the function...
10
by: Joseph Turian | last post by:
Is it possible to allow a class to be converted to bool? For example, if I have: class foo { private: unsigned i; }; and I want to evaluate: if (foo)
5
by: michal | last post by:
hi guys, i thought you might be interested in a nice JSON class which converts ASP datatypes (basic datatypes, dictionaries, recordsets, ...) into JSON so that javascript can easily understand it...
2
by: Tracey | last post by:
How can I convert to a string (what I thought was a string)? and/or How can I assign the value of a selected item in a list box to Label1.Text? using VB in VS2005. Thanks, Tracey I completed...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
5
by: newsaboutgod | last post by:
I think VB.NET drives some people crazy because some simple VB6 things seem so hard. Here is some VB6 code: 'Write CSV File open "c:\test.csv" for output as #1 write#1, "1","2","3","4","5"...
6
by: Patient Guy | last post by:
I am a newcomer to using PHP but not to programming (C, C++, Javascript). I am playing around with classes and wanted to make a function that has a method simply for producing either plain text...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.