Assigning vallues to fields in user control - help me please?

J

JJ_377

I made a user control to gather usa address information and would like
to know why the following doesn't work (I am assigning the valid of
textbox in a second instance of the control from the first instance of
the control) The textboxes hold date values.

If Len(USAAddress1.ValidFromCur) > 0 Then
USAAddress2.ValidFromCur = USAAddress1.ValidFromCur
End If

Here is the Property method in the user control's class file:

Public Property ValidFromCur()
Get
Return Me.txtValidFromCur
End Get
Set(ByVal Value)
Me.txtValidFromCur.Text = Value
End Set
End Property

Public Property ValidToCur()
Get
Return Me.txtValidToCur
End Get
Set(ByVal Value)
Me.txtValidToCur.Text = Value
End Set
End Property

For the other child controls there is no problem with this. I can
assign things such as Street Address 1, City, etc.

The only way this works is if I append ".text", such as
If Len(USAAddress1.ValidFromCur.Text) > 0 Then
USAAddress2.ValidFromCur.Text = USAAddress1.ValidFromCur.Text
End If


This *bugs* me because I considered I've already done this in the above
property method...Can someone help? What is the *proper* way to do
this?

Thank you. (very much)
 
K

Karl Seguin

Turn option strict on.

The ValidFromCur getter returns the actual textbox, and the setter expects a
string...option strict would have pointed that out to you.

seems like it should be

return Me.txtValidFromCur.Text

Karl
 
J

JJ_377

You are right, I didn't return the text property in the property
method...
Thank you again...
 

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,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top