|
Subject:
|
binding a constituent control to property
|
|
Posted By:
|
ParadiseIsle
|
Post Date:
|
11/10/2005 9:48:37 PM
|
Sorry to trouble y'all again, but the MSDN site (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconbuildingolecontrols.asp) says when binding a constituent control to a property of a custom actives control, use the following:
Property Get AddressLine1() As String
AddressLine1 = txtAddressLine1.Text
End Property
Public Property Let AddressLine1(NewValue As String)
If CanPropertyChange("AddressLine1")
txtAddressLine1.Text = NewValue
' The following line tells Visual Basic the
' property has changed--if you omit this line,
' the data source will not be updated!
PropertyChanged "AddressLine1"
End If
End Property
So for my project, I did it:
Public Property Get dim1() As Single
dim1 = txtdim1.text
End Property
Public Property Let dim1(ByVal New_Dim1 As Single)
If CanPropertyChange("Dim1") Then
txtdim1.Text = New_Dim1
PropertyChanged "Dim1"
End If
End Property
The problem is that I get a Type Mismatch error in my Property Get procedure: dim1=txtdim1.text line when I try to click on the txtdim1 textbox in design mode. I even get the same error if I use dim1=CSng(txtdim1.text). Any reason why this should be?
|
|
Reply By:
|
marcostraf
|
Reply Date:
|
11/11/2005 1:08:44 PM
|
the line
dim1=txtdim1.text
gets a type mismatch every time the string in the text box cannot be converted to a number (for eaxmple, when it is empty...)
Add error handling. Marco
|