Results 1 to 3 of 3

Thread: Simple Validation not working (sample attached)

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Question Simple Validation not working (sample attached)

    In a visually inherited form, I'm doing the following:

    VB Code:
    1. Overrides Sub Textbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    2.         strTempVar = ""
    3.  
    4.         strTempVar = Me.TextBox1.Text
    5.  
    6.         If IsValid(strTempVar) Then
    7.             Debug.Write("valid")
    8.             Me.TextBox2.Text = strTempVar
    9.         End If
    10.  
    11.     End Sub
    12.  
    13.  
    14. Public Function IsValid(ByVal cstrTempVar As String) As Boolean
    15.         If Len(cstrTempVar) < 10 Then
    16.             IsValid = True
    17.         Else
    18.             IsValid = False
    19.  
    20.         End If
    21.     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 Attached Files

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    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.

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    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
  •  



Click Here to Expand Forum to Full Width