[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Forms - Editing Form text boxes from a class

Posted on 2006-04-12
2
Medium Priority
?
299 Views
Last Modified: 2010-04-23
All,

Vb.Net 2005.

Say i have 2 forms that both have a textbox called textbox1, how can i set to update this from a different class.

i was expecting something like .........

' Call from either for1 or form 2
editTheBox(me)

then in the different class ....

sub editTheBox(ByVal frm as windows.Forms.Form)

frm.TextBox1.text = "hello"

end sub

This (in hindsight) obviously did not work because it did not know what form to reference, and i became aware that the only way i could get this to work was to use something like .....

sub editTheBox(ByVal frm as Frm1)

frm.TextBox1.text = "hello"

end sub

The problem is this only works for form1 now, but i wanted it to be generic to work for form1 and form 2. (In the real app this will be referenced by 3 forms if i can get it working).

Any ideas, anyone ?

Thanks,

Daz



0
Comment
Question by:yo_daz_uk
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 400 total points
ID: 16436232
How about something like:

    Public Shared Sub UpdateTextbox(ByVal frm As System.Windows.Forms.Form)

        Dim ctl() As System.Windows.Forms.Control
        ctl = frm.Controls.Find("TextBox1", True)

        If ctl.Length = 1 Then
            If TypeOf ctl(0) Is TextBox Then
                CType(ctl(0), TextBox).Text = "Hello world"
            End If
        End If

    End Sub
0
 

Author Comment

by:yo_daz_uk
ID: 16436835
Thats great cheers!!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question