I am working on a project where the developer has used user controls throughout his forms.
My question is this, he has one that is simply just a label and text box together, hence the name ctlLabelandTextBox.
My problem is that I cannot set the maxlength property which u normally get with a textbox.
Does anyone know how to enable this - i've attached the file. I can think of many reasons for user controls but can't see any real advantage for this one, however - i need to keep with the program if u know what i mean.
It is most likely that he did not include the property when he made the control. I am not sure that you can change it without having the source for the control.
But then again... I have been wrong in the past.
Mega.
"If at first you don't succeed, then skydiving is not for you"
Public Property Get Midpoint() As Long
Midpoint = txtTextBox.Left
End Property
Public Property Let Midpoint(lTwips As Long)
txtTextBox.Left = lTwips
UserControl_Resize
End Property
Public Property Get TextWidth() As Long
TextWidth = txtTextBox.Width
End Property
Public Property Let TextWidth(lTwips As Long)
txtTextBox.Width = lTwips
End Property
Public Property Get Text() As String
Text = txtTextBox.Text
End Property
Public Property Let Text(sText As String)
If msDataFormat > "" Then
txtTextBox.Text = Format$(sText, msDataFormat)
Else
txtTextBox.Text = sText
End If
End Property
Public Property Get Caption() As String
Caption = lblLabel.Caption
End Property
Public Property Let Caption(sText As String)
lblLabel.Caption = sText
End Property
Public Property Get Enabled() As Boolean
Enabled = txtTextBox.Enabled
End Property
Public Property Let Enabled(bEnabled As Boolean)
txtTextBox.Enabled = bEnabled
txtTextBox.BackColor = IIf(bEnabled, vbWhite, RGB(220, 220, 220))
End Property
Public Property Get DataFormat() As String
DataFormat = msDataFormat
End Property
Public Property Let DataFormat(sValue As String)
msDataFormat = sValue
End Property
Public Property Get Midpoint() As Long
Midpoint = txtTextBox.Left
End Property
Public Property Let Midpoint(lTwips As Long)
txtTextBox.Left = lTwips
UserControl_Resize
End Property
Public Property Get TextWidth() As Long
TextWidth = txtTextBox.Width
End Property
Public Property Let TextWidth(lTwips As Long)
txtTextBox.Width = lTwips
End Property
Public Property Get Text() As String
Text = txtTextBox.Text
End Property
Public Property Let Text(sText As String)
If msDataFormat > "" Then
txtTextBox.Text = Format$(sText, msDataFormat)
Else
txtTextBox.Text = sText
End If
End Property
Public Property Get Caption() As String
Caption = lblLabel.Caption
End Property
Public Property Let Caption(sText As String)
lblLabel.Caption = sText
End Property
Public Property Get Enabled() As Boolean
Enabled = txtTextBox.Enabled
End Property
Public Property Let Enabled(bEnabled As Boolean)
txtTextBox.Enabled = bEnabled
txtTextBox.BackColor = IIf(bEnabled, vbWhite, RGB(220, 220, 220))
End Property
Public Property Get DataFormat() As String
DataFormat = msDataFormat
End Property
Public Property Let DataFormat(sValue As String)
msDataFormat = sValue
End Property
I copied in your control over mine, when i play the project i get the error. I have not yet tried to set the property. I was just checking to see that the app still runs with the new property available.
I get a type mismatch on that line as soon as I load a form that contains the control.
Thats weird. I tested it out and it works. Perhaps you should
remove that control from the form, and then re-add it with the
same name. It might be that the form is conflicting with the new
control code.
Originally posted by wanhobi I copied in your control over mine, when i play the project i get the error. I have not yet tried to set the property. I was just checking to see that the app still runs with the new property available.
I get a type mismatch on that line as soon as I load a form that contains the control.
any ideas?
I assume that the problem is that the Property MaxLength is being declared as an Integer. In the read property section you are giving maxlength a string as it's default value.
Originally posted by wanhobi i get variable not defined on the line:
Originally posted by MarkT I assume that the problem is that the Property MaxLength is being declared as an Integer. In the read property section you are giving maxlength a string as it's default value.