Board index » Visual Studio » Class with property named "Type"

Class with property named "Type"

Visual Studio346
Hi,



I have an existing dll which I am instantiating using CreateObject and

passing an object (type object) to it using a method exposed by the

dll. The variable that i am passing to the dll has a reference to an

object of a class that I have created. The dll is expecting the object

to have a property called "Type" which is of the type string. Since

type is a keyword in VB, I am not able to create such a property. How

do I accomplish this. Is there some way of using 'alias' naming or

something. any help is appreciated.



Thanks

Teja


-
 

Re:Class with property named "Type"

<ndteja@gmail.com>wrote in message

Quote
I have an existing dll which I am instantiating using CreateObject and

passing an object (type object) to it using a method exposed by the

dll. The variable that i am passing to the dll has a reference to an

object of a class that I have created. The dll is expecting the object

to have a property called "Type" which is of the type string. Since

type is a keyword in VB, I am not able to create such a property. How

do I accomplish this. Is there some way of using 'alias' naming or

something. any help is appreciated.



I'm a bit confused about what you are doing. I think you are confusing User

Defined Type with object which are 2 different things in VB. I presume you

have an ActiveX dll written in another language and you are passing in a

User Defined Type to it and that UDT is being defined in VB. If that's the

case then you can probably just define the UDT with a different variable

name instead of Type, as long as the structure of the UDT is the same it

should work.



Michael





-

Re:Class with property named "Type"

Hi Michael,



Thanks for the quick reply. I am not using any UDTs. Let me put it

this way... The dll is expecting a particular object heirarchy.



I have a class called Application which has

Public Window as Object



another class called 'MapWindow'



I did

set app = new Application

set app.Window = new MapWindow

...

set obj = CreateObject("...")

obj.Initialize(app)



The thing is the DLL (which is also in VB) does this

Sub Initialize( App As Object )

if App.Window.Type = ... then

...

(There is not typecasting being done in the dll)

The DLL also try to access other properties of the window object and

that is working fine. My problem is that I have to have a property by

the name 'Type' in this MapWindow class



-

Re:Class with property named "Type"

<ndteja@gmail.com>wrote in message

Quote
(There is not typecasting being done in the dll)

The DLL also try to access other properties of the window object and

that is working fine. My problem is that I have to have a property by

the name 'Type' in this MapWindow class



Would I be correct in saying that the problem boils down to you needing to

call a property "Type". As far as I know it can't be done. Is there a reason

it must be called Type?



Michael





-

Re:Class with property named "Type"

It has to be Type because this is all a part of a larger framework and

the dll is actually a plugin I wrote for an application. The

application exposes the above mentioned heirarchy. The app is very

large and complex and it takes forever for it to load all the tools in

it (most of which r unlikely to be used in this senario). So the

program that i am now writing is an extremly simplified and highly

customized version of the big app. So I am trying to make the plugins

of that app work here and have been success in most of the plugins

except the ones which access the type property of the MapWindow class.

That is where I currently am. Thanks anyway for listenting



bye

Teja



-

Re:Class with property named "Type"

<ndteja@gmail.com>wrote in message

Quote
It has to be Type because this is all a part of a larger framework and

the dll is actually a plugin I wrote for an application. The

application exposes the above mentioned heirarchy. The app is very

large and complex and it takes forever for it to load all the tools in

it (most of which r unlikely to be used in this senario). So the

program that i am now writing is an extremly simplified and highly

customized version of the big app. So I am trying to make the plugins

of that app work here and have been success in most of the plugins

except the ones which access the type property of the MapWindow class.

That is where I currently am. Thanks anyway for listenting



I think I see what you're trying to do now. I think the answer is to define

the interface for the class in a type library and implement that in your

class. It's been a while since I've done it but the basic outline is

something like this:



Create a IDL code for your class in notepad.

Compile this to a type library using MIDL.exe or something like that.

Add this as a reference to your VB project.

implement this interface in your class

Pass the class into your dll.



I'm not sure if it will work but it's probably your best shot.



Hope this helps,

Michael



Quote


bye

Teja







-

Re:Class with property named "Type"

Hi Micheal,



Thats sounds very promising. I am going to try it now.



Thanks

Teja



-

Re:Class with property named "Type"

Hi,



Just adding this so that this thread doesnt end with this issue

unsolved. I tried your suggestion, and it probably would have worked,

if not for my incompetence with MIDL and VC in general. But anyway I

did something funny and it actually worked. I created a new activex dll

project in VB and created the class with all the necessary properties

and methods and when it came to creating the property called 'type' , i

called it 'typf' and created the dll. Then I opened the dll file in

editplus and changed the 2 occurances of 'typf' to 'type' and what do

you know...it works. I was almost certain that I would get an error if

i modified the dll, but it worked.



thanks for all the help

Teja



-

Re:Class with property named "Type"

You have got to be joking!!!!!!!!!!!!!!!!!!!!!!!



What about occurrences of "t y p f" where the characters are seperated by

chr(0)?



To me the obvious answer is to to declare the name of your property as

[Type]. The square brackets around an identifier feature is provided

especially so that you can use a reserved word as an identifier.





<ndteja@gmail.com>wrote in message

Quote
Hi,



Just adding this so that this thread doesnt end with this issue

unsolved. I tried your suggestion, and it probably would have worked,

if not for my incompetence with MIDL and VC in general. But anyway I

did something funny and it actually worked. I created a new activex dll

project in VB and created the class with all the necessary properties

and methods and when it came to creating the property called 'type' , i

called it 'typf' and created the dll. Then I opened the dll file in

editplus and changed the 2 occurances of 'typf' to 'type' and what do

you know...it works. I was almost certain that I would get an error if

i modified the dll, but it worked.



thanks for all the help

Teja







-

Re:Class with property named "Type"

Could you please give an example of correct syntax. This one:



Public Function [Type]() As String

End Function



is definitely not gonna work.



Dmitriy.



"Stephany Young" <noone@localhost>wrote in message

Quote
You have got to be joking!!!!!!!!!!!!!!!!!!!!!!!



What about occurrences of "t y p f" where the characters are seperated by

chr(0)?



To me the obvious answer is to to declare the name of your property as

[Type]. The square brackets around an identifier feature is provided

especially so that you can use a reserved word as an identifier.





<ndteja@gmail.com>wrote in message

news:1112594019.520030.112890@o13g2000cwo.googlegroups.com...

>Hi,

>

>Just adding this so that this thread doesnt end with this issue

>unsolved. I tried your suggestion, and it probably would have worked,

>if not for my incompetence with MIDL and VC in general. But anyway I

>did something funny and it actually worked. I created a new activex dll

>project in VB and created the class with all the necessary properties

>and methods and when it came to creating the property called 'type' , i

>called it 'typf' and created the dll. Then I opened the dll file in

>editplus and changed the 2 occurances of 'typf' to 'type' and what do

>you know...it works. I was almost certain that I would get an error if

>i modified the dll, but it worked.

>

>thanks for all the help

>Teja

>









-

Re:Class with property named "Type"

Oh my God!!!! Is that all there is to it. I have to try it. Anyway if

you want to try out what I did open the dll in any editor. there are 2

occuraces of the word (typf in this case, there are no spaces, a few

before and after but none inbetween). Change the first occarance of the

word typf to type and leave the second occarance as it is. It works.

Quote
From the vb program i am accessing it as 'typf' and passing the object

to the dll. the dll is accessing it as 'type'. This is truely amaizing.



Teja



-

Re:Class with property named "Type"

I stand corrected on the [Type] thing.



However, I will NOT be trying what you advocate as it is probably the single

most dangerous thing that one could possibly do to an object code file. I

would consider deleting the file less dangerous than doing what you

advocate.



If any of my staff were to do such a thing they would summarily dismissed

for gross misconduct.





<ndteja@gmail.com>wrote in message

Quote
Oh my God!!!! Is that all there is to it. I have to try it. Anyway if

you want to try out what I did open the dll in any editor. there are 2

occuraces of the word (typf in this case, there are no spaces, a few

before and after but none inbetween). Change the first occarance of the

word typf to type and leave the second occarance as it is. It works.

>From the vb program i am accessing it as 'typf' and passing the object

to the dll. the dll is accessing it as 'type'. This is truely amaizing.



Teja







-

Re:Class with property named "Type"

Hey Stephany, take it easy! This is the kind of stuff that makes

programming interesting to me. In any case if you think about it, there

are hundreds of way to create a dll. You can create it with even ada

for that matter. I am now creating it with an editor. anyway it is a

dll that I just created...not someone else's or some proprietry dll.

Since I created it I think I decide when the creation of the dll is

completed, (Which is after i have changed the 'f' to 'e'). So in

essense i didnt make any more change to the object code than what one

does when he/she renames a variable and recompiles the code. Any way,

take it easy...enjoy life...



Teja



-