![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | declare a form so that you can reference it's controls On Jul 4, 8:30*pm, breitak67 <gu...@xxxxxx-email.com> wrote: Quote: > TextBox1 is not a member of System.Windows.Forms.Form - it is a member > of the Form1 class, which is a subclass of System.Windows.Forms.Form. > Try this: > > Public Class Form1 > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > Utilities.SetControl(Me, \"ExampleText\") > End Sub > End Class > > Public Class Utilities > Public Shared Sub SetControl(ByRef MyForm As Form1, ByVal > MyTextVal As String) > MyForm.TextBox1.Text = MyTextVal > End Sub > End Class > > If you need the flexibility to set the text of forms that are of class > Form1, then pass a reference to the control instead of the form, like > this: > > Public Class Form1 > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > Utilities.SetControl(Me.TextBox1, \\"ExampleText\\") > End Sub > End Class > > Public Class Utilities > Public Shared Sub SetControl(ByRef MyTextBox As TextBox, ByVal > MyTextVal As String) > MyTextBox.Text = MyTextVal > End Sub > End Class > > -- > breitak67 |
My System Specs![]() |
| | #2 (permalink) |
| Vista Business x64 | Re: declare a form so that you can reference it's controls TextBox1 is not a member of System.Windows.Forms.Form - it is a member of the Form1 class, which is a subclass of System.Windows.Forms.Form. Try this: PublicClass Form1 PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Utilities.SetControl(Me, "ExampleText") EndSub EndClass PublicClass Utilities PublicSharedSub SetControl(ByRef MyForm As Form1, ByVal MyTextVal AsString) MyForm.TextBox1.Text = MyTextVal EndSub EndClass If you need the flexibility to set the text of forms that are of class Form1, then pass a reference to the control instead of the form, like this: PublicClass Form1 PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Utilities.SetControl(Me.TextBox1, "ExampleText") EndSub EndClass PublicClass Utilities PublicSharedSub SetControl(ByRef MyTextBox As TextBox, ByVal MyTextVal AsString) MyTextBox.Text = MyTextVal EndSub EndClass |
My System Specs![]() |
| | #3 (permalink) |
| | Re: declare a form so that you can reference it's controls On Jul 4, 8:30*pm, breitak67 <gu...@xxxxxx-email.com> wrote: Quote: > TextBox1 is not a member of System.Windows.Forms.Form - it is a member > of the Form1 class, which is a subclass of System.Windows.Forms.Form. > Try this: > > Public Class Form1 > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > Utilities.SetControl(Me, \"ExampleText\") > End Sub > End Class > > Public Class Utilities > Public Shared Sub SetControl(ByRef MyForm As Form1, ByVal > MyTextVal As String) > MyForm.TextBox1.Text = MyTextVal > End Sub > End Class > > If you need the flexibility to set the text of forms that are of class > Form1, then pass a reference to the control instead of the form, like > this: > > Public Class Form1 > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e > As System.EventArgs) Handles Button1.Click > Utilities.SetControl(Me.TextBox1, \\"ExampleText\\") > End Sub > End Class > > Public Class Utilities > Public Shared Sub SetControl(ByRef MyTextBox As TextBox, ByVal > MyTextVal As String) > MyTextBox.Text = MyTextVal > End Sub > End Class > > -- > breitak67 |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Declare type for hashtables? | PowerShell | |||
| Declare in vb script? | VB Script | |||
| Winforms User Controls - How do I bind those to a dataset on the host form | .NET General | |||