p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Visual Basic 2005 Basics (http://p2p.wrox.com/visual-basic-2005-basics-137/)
-   -   Text Box .text Property Displays conflicting Valus (http://p2p.wrox.com/visual-basic-2005-basics/46833-text-box-text-property-displays-conflicting-valus.html)

JPOhlman August 22nd, 2006 08:35 PM

Text Box .text Property Displays conflicting Valus
 
 Here is the Problem:

I created a user control called PersonalDetails,

Then in the code for the main form for a button (called 'new person') I added this code:
Code:

ObjPersonalDetails = New PersonalDetails


Later I asked the computer to:
Code:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ObjPersonalDetails IsNot Nothing Then
            MsgBox(ObjPersonalDetails.TextBoxAddress.Text)
        End If
    End Sub





when I clicked the right button:
the mesage box stated "11432 FM 957"
However In the code of personaldetails I included this:

Code:

Private Sub TextBoxAddress_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBoxAddress.MouseClick
        MsgBox(TextBoxAddress.Text)


    End Sub


When I clicked button1 msgbox: "11432 FM 957"
When I cliked on TextBoxAddress msgBox: ""

Does anyone know what is going on?

___________________________
In Him,
Joshua

dilionyi August 23rd, 2006 06:30 AM

hello joshua,
try this in place of what u have

Private Sub TextBoxAddress_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBoxAddress.Click
        MsgBox(TextBoxAddress.Text)
End Sub

use the click event instead of the mouseclick event which u are using
hope this works



dilionyi August 23rd, 2006 06:35 AM

sorry it should be this

Private Sub TextBoxAddress_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBoxAddress.Click
        MsgBox(TextBoxAddress.Text)
End Sub



JPOhlman August 23rd, 2006 02:39 PM

Thanks, but that's not the problem,

The problem is that the same text box has two different values.
If you address it from the main form it says that the .text property is:

    "11432 FM 957"

while if you adress it from it's own control it says that the .text property is :

    ""

___________________________
In Him,
Joshua


All times are GMT -4. The time now is 03:26 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.