473,799 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem passing a structure and using GetType.

dcs
Hi,
Can someone please help. I have a class that contains the following
Structure (called MyStructure) and sub (called MainSub). And this 1st
class inherits a 2nd class that contains a sub called
Get_Values_From _MyStructure. My problem is in sub
Get_Values_From _MyStructure. Since Get_Values_From _MyStructure is
inherited by many different classes, its parameter i_obj_Structure will
contain various Structure definitions. And thats a problem when using
GetType(). I have tried substitutng the code GetType(i_obj_S tructure)
in place of GetType(MyStruc ture) but it didn't work. PLEASE HELP. Thank
you VERY much
-Doug

Public Structure MyStructure
Public Field1 As String
Public Field2 As Boolean
End Structure 'MyStructure
Public Sub MainSub
Dim l_MyStructure As New MyStructure 'Local Structure
l_MyStructure.F ield1 = "AA"
l_MyStructure.F ield2 = True
Call Get_Values_From _MyStructure(l_ MyStructure)
End Sub 'MainSub
Private Sub Get_Values_From _MyStructure (ByVal i_obj_Structure As
Object)
'-------------------------------------------------------
'-- This works. But Instead of hardcoding MyStructure
'-- in the GetType(MyStruc ture), I need to have the
'-- structure type that is passed in the parameter
'-- i_obj_Structure , since MyStructure willnot always
'-- be used.
'-------------------------------------------------------
Dim l_FieldInfo As Reflection.Fiel dInfo =
GetType(MyStruc ture).GetField( "Field1")
MsgBox("Get value:" & l_FieldInfo.Get Value(i_obj_Str ucture))
End Sub 'Get_Values_Fro m_Record 'Get_Values_Fro m_Structure

Feb 3 '06 #1
1 1495
I have tried substitutng the code GetType(i_obj_S tructure)
in place of GetType(MyStruc ture) but it didn't work.


Make it i_obj_Structure .GetType()
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 6 '06 #2

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

Similar topics

1
1857
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which causes ie problems. But when deserializing the xml into the object structure, the following exception is beeing thrown: There is an error in XML document (3, 701).
15
14882
by: John Alway | last post by:
Hello, I'm using a DLL I wrote in C++, and am attempting to call and use it from VB. This works fine for functions where I pass parameters by value, but I can't get pointers to work. I get the following error in the VB.net application: "An unhandled exception of Type
2
2855
by: Phoenix | last post by:
Hi Friends , Could anyone please help me to resolve the following issue : I pass an array of structures to a dll written in VC++ 6.0 whih fills it with data . The following works well for VB 6.0 but when I wrote the same piece of code in VB 2005 the array of structures remained empty even after the API call : I have a structure as follows :
43
2392
by: John | last post by:
Hi This .net is driving me crazy!! In VB6 I had a type which contained a couple of multi-dimentional arrays which i used to create and read records: Type AAA : Array1(10,10,2) as Integer
0
9687
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
10484
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
10251
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
10228
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
10027
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...
1
7565
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.