passing several textbox.text between forms

johmolan

Well-known member
Joined
Oct 11, 2008
Messages
129
Programming Experience
Beginner
I use the code
VB.NET:
Dim Selvk As New Selvkost2
        Selvk.PassedText = TextBox29.Text
                Selvk.Show()
in mainform and the code
VB.NET:
Private _passedText As String
 
    Public Property [PassedText]() As String
        Get
            Return _passedText
        End Get
        Set(ByVal Value As String)
            _passedText = Value
        End Set
    End Property
in my second form and the text passes. but I need to pass values from 20 textboxes.
do I have to copy the code in my second form 20 times an declare passedtext2 and so on or is there an easier way to do this?
 
Depends on the purpose of the strings. If you're passing to set for example designed textboxes in other form there is already form fields for these that can be set directly.
If the strings have no special designation or meaning you can expose a single collection property that caller adds values to, or array property where caller passes all values in one go.
 
VB.NET:
selvk.TargetTextBox.Text = Me.SourceTextBox.Text
 
Back
Top