I have a problem on passing value from Main Form to 2nd Form. Actually, I have a 2nd Form on the SplitContainer and the SplitContainer is placed inside the Main form.

What I want to do is Click the Button on the 2nd Form from the Main Form.


Thanks in advance.

Recommended Answers

All 5 Replies

First, may I ask why you would want to do this? Wouldn't it just be easier to put the button on the form you were using? Anyways, I will try to help.

You could try something like this. On Form2 add the Following Sub:

Public Sub Command2_Click()
        'Your Code Here
    End Sub

Now on Form1 we need to create this Public Sub:

Public Sub Command1_click()
        Form2.Command2_Click()
    End Sub

Now on Form1's button we need to add the following code:

Command1_Click()

This will make the button on Form1 access the code on Form2. Also you can add the following code to the button on Form2 so that button will carry out the same code as the sub:

Command2_Click()

This isn't exactly what you asked for but this is close. If not, then this will get you started.

I think your code is for VB6 and not on VB.net.

Anyway, thanks for your help.

I think your code is for VB6 and not on VB.net.

Anyway, thanks for your help.

No, this is in Visual Basic 2010 Express.

Really, but I also use Visual Basic 2010. and it didn't work.

Make sure you are making it a Public Sub otherwise it will not work. Also, if you would like you can send me the errors you are receiving so I can troubleshoot it with you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.