Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you reference all class members within a class function?

Status
Not open for further replies.

roblasch

Programmer
Dec 30, 2000
168
US
In the following code, I am unsure of how to search through the members of the class to see if there are any matches.

Public Class FormError
Dim Name As String
Dim FormValue As String
Dim hasError As Boolean
Public Sub New(ByVal n As String, ByVal v As String, ByVal e As Boolean)
Name = n
FormValue = v
hasError = e
End Sub
Public Sub Validate()
'Step through all other members of this class to see if any of the formValues match this members formValue
End Sub

 
Can you show me an example of how you would use this in my code, in the validate sub, to step through each member and check the formValue field?
 
Does the formerror class have more members then the 3 you showed? Are you comparing it to other classes? Are you saying that you want to see if formvalue equals name for example? For the moment you have just 3 members 1 formvalue and 1 other string so you only need to compare it to that.


Christiaan Baes
Belgium

"My new site" - Me
 
>>You can use Reflection to do this. Have a read up on the Reflection class here:

really intersted in this. I have only loaded classes into memory using the reflection class. never loaded the Current object and tried to read through its members (using a generic loop).

any tutorials???

Known is handfull, Unknown is worldfull
 
I'm not sure of any good tutorials but the MemberInfo class which is part of System.Reflection is what you'll need to look at. There is an example in the help files as well which should give you some pointers:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
hmm,

let me look into it and let you know...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top