By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,363 Members | 621 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,363 IT Pros & Developers. It's quick & easy.

Refer to Different Forms in same SubProcedure

cindy2
P: 35
Hi everybody,

In my vb2005-project I have a subprocedure (in a MODULE) like this:
Expand|Select|Wrap|Line Numbers
  1. Public Sub MakeInputArray()
  2.      Input(0) = Form2.TextBox1.Text
  3.      Input(1) = Form2.TextBox2.Text
  4. End Sub
  5.  
You can see that the procedure refers to Form2. I want to use the exact same procedure to refer to Form3 too. I want something like this:
Expand|Select|Wrap|Line Numbers
  1. Public Sub MakeInputArray()
  2.       Input(0) = FormGeneral.TextBox1.Text
  3.       Input(1) = FormGeneral.TextBox2.Text
  4. End Sub
  5.  
Next I only have to define FormGeneral. For example:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button1_Click(......
  2.       FormGeneral = Form3
  3.       MakeInputArray()
  4. End Sub
  5.  
But this doesn't work. Does somebody know how I can refer to different forms in the exact same procedure?

Cindy
Oct 4 '07 #1
Share this Question
Share on Google+
2 Replies

Dököll
Expert 100+
P: 2,364
Hi everybody,

In my vb2005-project I have a subprocedure (in a MODULE) like this:
Expand|Select|Wrap|Line Numbers
  1. Public Sub MakeInputArray()
  2.      Input(0) = Form2.TextBox1.Text
  3.      Input(1) = Form2.TextBox2.Text
  4. End Sub
  5.  
Does somebody know how I can refer to different forms in the exact same procedure?

Cindy
Please stay tuned for additional help...

I will add an diea here perhaps that'll spring in the right direction. Judging by the way VB6 work, I wonder if making one form invisible to bring forth another would work:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub SwitchForms_Click()
  3.  
  4.     If SwitchForms.Enabled Then
  5.        Form1.Visible=False
  6.        Form2.Visible=True
  7.     End If
  8.  
  9. End Sub
  10.  
  11.  
That's the idea, I'd have to look to see what can be done with VB 2005. Also if you haven't already, a video is available for Express 2005, there may be some pointers there if you're interested: http://msdn2.microsoft.com/en-us/express/aa718409.aspx
Oct 5 '07 #2

cindy2
P: 35
Please stay tuned for additional help...

I will add an diea here perhaps that'll spring in the right direction. Judging by the way VB6 work, I wonder if making one form invisible to bring forth another would work:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub SwitchForms_Click()
  3.  
  4.     If SwitchForms.Enabled Then
  5.        Form1.Visible=False
  6.        Form2.Visible=True
  7.     End If
  8.  
  9. End Sub
  10.  
  11.  
That's the idea, I'd have to look to see what can be done with VB 2005. Also if you haven't already, a video is available for Express 2005, there may be some pointers there if you're interested: http://msdn2.microsoft.com/en-us/express/aa718409.aspx
Thanks for your reply, but I don't understand. The issue i'm troubled with is as follows:
I have two textboxes on form1: Textbox1 and textbox2
On form2 I have also two textboxes: Textbox1 and Textbox2.
As you can see the textboxes on both forms have the exact same name. Now, in my module I have a procedure as written above. I want to use the procedure either way: 1) the inputarray must be filled with textbox1 and textbox2 of form1, Or 2) the inputarray must be filled with textbox1 and textbox2 of form2. I want the abbility to choose (in the procedure) which textboxes will be written in the inputarray.
I don't understand how your idea works for this issue. Can you help me?

Cindy
Oct 5 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.