May 2nd, 2004, 12:25 AM
#1
Simple Validation not working (sample attached)
In a visually inherited form, I'm doing the following:
VB Code:
Overrides Sub Textbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
strTempVar = ""
strTempVar = Me.TextBox1.Text
If IsValid(strTempVar) Then
Debug.Write("valid")
Me.TextBox2.Text = strTempVar
End If
End Sub
Public Function IsValid(ByVal cstrTempVar As String) As Boolean
If Len(cstrTempVar) < 10 Then
IsValid = True
Else
IsValid = False
End If
End Function
Where textbox2 belongs to the new form only. It keeps breaking at the line:
Me.Textbox2.Text = strTempVar
When I move my mouse over Me.Textbox, the tooltip says Me.TextBox = Nothing
Anyways, it's a simple application, so I've attached it. Please tell me what I'm missing.
Attached Files
May 2nd, 2004, 05:47 AM
#2
My theory (could be wrong, I usually am).
In the Form2 Code:
The form1.InitializeComponent() sets textbox1.text before textbox2 is created in form2.InitializeComponent ()
Thus nothing.
The form2 InitializeComponent () sub is never called. The error is occurring before it.
I don't live here any more.
May 2nd, 2004, 05:51 AM
#3
I reckon that what you are trying to accomplish is a bit strange, you'd be better served overloading the form2 constructor and letting it take a string argument and querying it after InitializeComponent() has finished.
I don't live here any more.
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