[dba-VB] Setting a Textbox Variable

Dan Waters df.waters at comcast.net
Fri Aug 5 10:40:43 CDT 2011


All I had to do was get rid of the Set keyword.

Good to know about the other methods as well

Thanks!
Dan

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Shamil
Salakhetdinov
Sent: Saturday, July 30, 2011 5:25 AM
To: 'Discussion concerning Visual Basic and related programming issues.'
Subject: Re: [dba-VB] Setting a Textbox Variable

Yes, Don, your code should work as is - there are several other options
(VS2010):

        Dim txt As TextBox
        txt = Me.Controls("TextBox1")
or
        txt = Me.Controls.Item("TextBox1") or
        txt = CType(Me.Controls.Find("TextBox1", False)(0), TextBox) ...

Thank you.

--
Shamil
 
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Michael Maddison
Sent: 30 ???? 2011 ?. 6:06
To: df.waters at comcast.net; Discussion concerning Visual Basic and related
programming issues.
Subject: Re: [dba-VB] Setting a Textbox Variable

Hi Don,

Your code seems to work as is.
Are you sure you have a textbox with that name?

Cheers

Michael M

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Dan Waters
Sent: Saturday, 30 July 2011 3:39 AM
To: 'Discussion concerning Visual Basic and related programming issues.'
Subject: [dba-VB] Setting a Textbox Variable

In VB.Net, I'm trying to pass a listbox object into a procedure, get part of
the name of that listbox, and then set a textbox object to a specific
textbox using the partial name of the listbox.  In Access it's
easy:

    Public Sub XXX(lst As ListBox)

        Dim txt As TextBox
        Dim stg as String

        stg = "txt" & Mid(lst.Name, 4)
    
        Set txt = Me.Controls(stg)
    
    End Sub

Part of the answer is:

    stg = "txt" & lst.Name.Substring(0, 4)


But I don't know how to actually 'set' the textbox variable to a specific
textbox.

Thanks!


_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com


-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1390 / Virus Database: 1518/3797 - Release Date: 07/29/11

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com






More information about the dba-VB mailing list