Entering text into window?

starcraft

Centurion
Joined
Jun 29, 2003
Messages
167
Location
Poway CA
Can VB enter text into a textbox on another window? if not can it run a different program that is either built in or in the same folder to enter info into the textbox? :confused:
 
if you have a textbox on Form1 and you want to change it's text from Form2 , you can do this :

at top of Form2 , modify the Public Sub New()
Visual Basic:
Public Class Form2

    Inherits System.Windows.Forms.Form
    Public frm As Form1 '/// first make a public reference to your form ( eg: Form1 )

#Region " Windows Form Designer generated code "

    Public Sub New(ByVal myForm As Form) '/// make myForm as a Form ( not Form1 )
        MyBase.New()
        'This call is required by the Windows Form Designer.
        InitializeComponent()
        frm = myForm '/// initialize the instance of the form as Form1.
        'Add any initialization after the InitializeComponent() call

    End Sub

from a command button on Form2 :
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        frm.TextBox1.Text = "i am some text from form2 to form1's textbox!"

    End Sub

to show the Form2 , do this in Form1 :
Visual Basic:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frmTwo As New Form2(Me)
        frmTwo.Show()
    End Sub
 
Back
Top