473,386 Members | 1,943 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,386 software developers and data experts.

get menber name,type of a structure

Cc
hi ,
how do I get menber of a structure on runtime?
for eample
Structure Person

<VBFixedString(10)> Public ID As String

<VBFixedString(15)> Public Name As String

End Structure

private sub calling()

dim pp as person

test(pp)

end sub

public function test(byref arg_struct as system.valuetype)

' in here I would like to get the menber and value

end function

'---------------------------------------------------------------------------
--

Note

Please don't suggest that I just declare as person on test function
parameter

rgds

cc
Nov 20 '05 #1
4 1370
Hi Cc,

I think what you should be doing is passing in your arg_struct declared as Person rather than ValueType. That way you will have
access to all the members.

Regards,
Fergus
Nov 20 '05 #2
Hi again Cc,

Alternatively, lol, you can do this:

public function test(byref arg_struct as system.valuetype)
If TypeOf arg_struct Is Person Then
Dim S As String = DirectCast (arg_struct, Person).ID
End If
end function

:-D

Regards,
Fergus
Nov 20 '05 #3
Cc
I found a way by doing this
Public Function test(ByVal arg_struct As ValueType)

Dim mi() As MemberInfo

Dim srmMemberInfo As MemberInfo

Dim myfieldinfo As FieldInfo

Dim typTmp As Type

typTmp = arg_struct.GetType()

mi = typTmp.GetMembers()

For Each srmMemberInfo In mi

MsgBox(srmMemberInfo.Name)

Next

end function
but I still don't know how to get the menber data type and size (if fixed
string is used)
"Fergus Cooney" <fi******@tesco.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi again Cc,

Alternatively, lol, you can do this:

public function test(byref arg_struct as system.valuetype)
If TypeOf arg_struct Is Person Then
Dim S As String = DirectCast (arg_struct, Person).ID
End If
end function

:-D

Regards,
Fergus

Nov 20 '05 #4
Hi Cc,

If the TypeOf .. DirectCast solution of no use to you?

Using Reflection is a lot of work. What exactly are you wanting to do?

Regards,
Fergus
Nov 20 '05 #5

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

Similar topics

2
by: Peter Dunker | last post by:
Hi, I will write ANSI C89. Is the following struct defenition correct ? I wrote it with VC6(Windows IDE) and at first no Problem. As I changed a compiler switch to 'no language extension', the...
34
by: prosoft | last post by:
When I use Dim myDTFI As DateTimeFormatInfo = New CultureInfo("he-IL", True).DateTimeFormat Dim strhmon1 As String = (myDTFI.GetMonthName(hmon1)) MsgBox(strhmon1) I get the local name of the...
2
by: csgraham74 | last post by:
Hello, just wondering if someone can help me - im using the following code to iterate around a structure and get the name of each varaibale in the structure. Basically i need to get the value of...
7
by: ot_007_2001 | last post by:
Hi, all, For pricticing defination of structure in C, I wrote a small code as follow: #include<stdio.h> struct datastruct { int data;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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,...
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...

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.