|
-
Aug 11th, 2000, 07:25 AM
#1
Thread Starter
Hyperactive Member
I'm having a bit of a problem with classes, now I've just started to use thes things.
I've got a class that checks a text box to make sure that you have entered a correct date format. Now this works fine on a single textbox with no Control array on it. The minute I make it a controlled array my class fails. How if at all do I pass the index across or is there anyway of doing this.
Please help 
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Aug 11th, 2000, 07:47 AM
#2
Fanatic Member
You can pass a control array text box just like a normal text box.
Code:
Private Function validate(txtBox As TextBox) As Boolean
End Function
'then you pass a text box like so.
myBoolean = validate(text1(1))
Iain, thats with an i by the way!
-
Aug 11th, 2000, 07:52 AM
#3
Thread Starter
Hyperactive Member
That doesn't seem to work for me for some reason.
Here is the class itself
Private WithEvents txtBox As TextBox
Public Property Set TextCtl(OTextBox As TextBox)
Set txtBox = OTextBox
End Property
Private Sub txtBox_LostFocus()
'checks for a date format
If txtBox <> "" Then
If IsDate(txtBox) Then
txtBox = Format(txtBox, "dd/mmm/yyyy")
Else
MsgBox "Not a correct date format", vbInformation, "Warning"
txtBox.SetFocus
End If
End If
End Sub
And this is how a call it
Sub Form_Load()
Set clsTextbox = New clsCheckDate
Set clsTextbox.TextCtl = txtTest
'Now I want to be able to reference txtTest as txtTest(0)
End Sub
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Aug 11th, 2000, 08:54 AM
#4
Frenzied Member
Eugh, this is a messy little problem. The error message I get is "Object does not support this set of events," Is that what you're getting?
If so then the reason this is happening is that when a textbox is part of an array it's events have an extra parameter called Index, this is raised as part of their events, your class does not support this version of the event, it only supports the type with no index parameter.
unfortunatley I can't think of a solution to this problem, but I can explain what's happening and maybe someone else will think of one.
sorry
-
Aug 11th, 2000, 09:01 AM
#5
Thread Starter
Hyperactive Member
Yes thats the same error I keep getting. I figured it had something to do with the index, but I've no idea how to transfer the index with it
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Aug 11th, 2000, 09:10 AM
#6
Fanatic Member
Just an idea, i haven't really thought this through, but could you have a collection of the Class?
Iain, thats with an i by the way!
-
Aug 11th, 2000, 09:30 AM
#7
Thread Starter
Hyperactive Member
I've no idea. I haven't really been using classes all that long.
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
-
Aug 11th, 2000, 09:57 AM
#8
Frenzied Member
Iain unfortunatley that isn't the problem, the problem is that if a textbox is part of a control array it raises different events than if it was not part of a control array, we can't find a way to handle the events of an element of a textbox array from inside a class module.
By the way, have you thought of using a usercontrol? just open up a usercontrol project and stick a textbox inside it, usercontrols have properties methods and events just like classes but have to be placed on the form, if you have a textbox placed on a usercontrol then you automaticly have a textbox and some date validation code with it as soon as you place one of these down. although haveing said that have you thought about the DTPicker control?
-
Aug 11th, 2000, 10:06 AM
#9
Thread Starter
Hyperactive Member
Many thanks for all your comments, I'll that date picker might sort a few problems
Thanks in advance for any help provided.
VB 6 Enterprise Edition SP4
ADO, SQL 7/2000, ASP and some JavaScript

>> Life goes on, but for how long? <<
If you can smile when things go wrong, you have someone in mind to blame
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|