Property. What is going on here?

S

shapper

Hello,

I created a Structure as follows:

' Pair
Public Structure Pair

' -- [Properties] ----

' Expression
Private _Expression As String
Public Property Expression() As String
Get
Return _Expression
End Get
Set(ByVal Expression As String)
_Expression = Expression
End Set
End Property ' Expression

' Regex
Private _Regex As RegularExpression
Public Property Regex() As RegularExpression
Get
Return _Regex
End Get
Set(ByVal Regex As RegularExpression)
_Regex = Regex
End Set
End Property ' Regex

' Valid
Private _Valid As Boolean
Public Property Valid() As Boolean
Get
Return _Valid
End Get
Set(ByVal Regex As Boolean)
_Regex = Regex
End Set
End Property ' Valid


' -- [Methods] ----

' New
Public Sub New(ByVal Expression As String, ByVal Regex As
RegularExpression)

' Define property values
Me.Expression = Expression
Me.Regex = Regex
Me.Valid = Valid

End Sub ' New

End Structure ' Pair

Then I have a function:

Public Overloads Shared Function Match(ByRef pairs As
Generic.List(Of Pair)) As Boolean

For Each pair As Pair In Pairs
> Added a Debug Watch HERE <
Next pair

End Function

I am using this function as follows:

Dim pairs As New Generic.List(Of Validation.Pair)
With pairs
'.Add(New Validation.Pair(tbCity.Text,
Validation.RegularExpression.NotEmpty, False))
'.Add(New Validation.Pair(tbEmail.Text,
Validation.RegularExpression.NotEmpty, False))
End With
Dim result As Boolean = Match(pairs)

This is not working and when I added a Watch, as I mention in this
post, I get:

pair {Pair} Pair
_Expression "Hello" String
_Regex 0
RegularExpression
_Valid False Boolean
Expression "Hello" String
Regex 0
RegularExpression
Valid False Boolean


What I see by my many tryings is that the value I define as expression
works fine.

However. the values of Regex and Valid are always 0 and False whatever
I define them.

I tried everything I could think of. But I have no idea what else to
do.

Thanks,

Miguel
 
G

Guest

Hello,

I created a Structure as follows:

' Pair
Public Structure Pair

' -- [Properties] ----

' Expression
Private _Expression As String
Public Property Expression() As String
Get
Return _Expression
End Get
Set(ByVal Expression As String)
_Expression = Expression
End Set
End Property ' Expression

'Regex
Private _Regex As RegularExpression
Public PropertyRegex() As RegularExpression
Get
Return _Regex
End Get
Set(ByValRegexAs RegularExpression)
_Regex =Regex
End Set
End Property 'Regex

' Valid
Private _Valid As Boolean
Public Property Valid() As Boolean
Get
Return _Valid
End Get
Set(ByValRegexAs Boolean)
_Regex =Regex
End Set
End Property ' Valid

' -- [Methods] ----

' New
Public Sub New(ByVal Expression As String, ByValRegexAs
RegularExpression)

' Define property values
Me.Expression = Expression
Me.Regex=Regex
Me.Valid = Valid

End Sub ' New

End Structure ' Pair

Then I have a function:

Public Overloads Shared Function Match(ByRef pairs As
Generic.List(Of Pair)) As Boolean

For Each pair As Pair In Pairs
Added a Debug Watch HERE <
Next pair

End Function

I am using this function as follows:

Dim pairs As New Generic.List(Of Validation.Pair)
With pairs
'.Add(New Validation.Pair(tbCity.Text,
Validation.RegularExpression.NotEmpty, False))
'.Add(New Validation.Pair(tbEmail.Text,
Validation.RegularExpression.NotEmpty, False))
End With
Dim result As Boolean = Match(pairs)

This is not working and when I added a Watch, as I mention in this
post, I get:

pair {Pair} Pair
_Expression "Hello" String
_Regex 0
RegularExpression
_Valid False Boolean
Expression "Hello" String
Regex 0
RegularExpression
Valid False Boolean

What I see by my many tryings is that the value I define as expression
works fine.

However. the values ofRegexand Valid are always 0 and False whatever
I define them.

I tried everything I could think of. But I have no idea what else to
do.

Thanks,

Miguel

The .Add Method is commented out. "Validation.Pair" has a False as a
third value, however the New Method has only two

Expression As String, ByValRegex As RegularExpression
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top