473,398 Members | 2,113 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,398 software developers and data experts.

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_Structure)
in place of GetType(MyStructure) 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.Field1 = "AA"
l_MyStructure.Field2 = 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(MyStructure), 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.FieldInfo =
GetType(MyStructure).GetField("Field1")
MsgBox("Get value:" & l_FieldInfo.GetValue(i_obj_Structure))
End Sub 'Get_Values_From_Record 'Get_Values_From_Structure

Feb 3 '06 #1
1 1474
I have tried substitutng the code GetType(i_obj_Structure)
in place of GetType(MyStructure) 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
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...
15
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...
2
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...
43
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...
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...

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.