pass data to different form when user key in different form name using textbox
I want let user pass a data through mscomm. My idea as below:
1. create a T1.form
2. create textbox1 and textbox2 at different form
3. user key in T1 at textbox1 and 2 in textbox2
4. the 2 will pass to msflexgrid.textmatrix(1,1) at form T1
5. the form name is create by user after the program done, not designer, so the designer would not know the form name
the idea example code:
---------------------
' the a is form name and selected by user
a = text1.text
'b is the data pass to the form
b = text2.text
'problem at here
a.msfelxgrid.textmatrix(1,1) = b
but this example cannot be use, can someone help for this or have other better idea other than this?
Re: pass data to different form when user key in different form name using textbox
As long as form was created in design time you may create an instance of it using vode similar to this:
Code:
Option Explicit
Private Sub Command1_Click()
Dim frm As Form
Dim myForm As Form
For Each frm In Forms
If LCase(frm.Name) = Trim(Text1.Text) Then
Set myForm = frm
Exit For
End If
Next frm
If myForm Is Nothing Then
Set myForm = Forms.Add(Trim(Text1.Text))
End If
myForm.Show
myForm.Text1.Text = Me.Text2.Text
End Sub