Skip to main content
gamedev.net
🔒 Locked

[VB.NET] - Multiple Forms problem!

Started by UltraMAX2K5 Jan 13, 2005 at 12:17 PM 2 replies 350+ views
Original Post
UltraMAX2K5
UltraMAX2K5
Hi, i'm trying now VB.NET and i got the follow problem: in VB6 i use the follow code in form2 button1_click event: form1.statusbar1.text = "SIMPLE TEST" here it works great, but how can i do the same thing in VB.NET, i've tried do this but it don't work: in form2 button1_click event: Dim frmMain As New Form1 frmMain.StatusBar1.Text = "SIMPLE TESTE" can someone help me please do this and the same thing for textboxes and other controls? Thanks UltraMAX2K5
alexmoura
alexmoura
the issue is that vb6 had default instances created for declared forms, while vb7 doesn't (it will again in 2005), and the way you're doing it you're creating a new, different form1 - so you won't see any changes you do to it unless you call show() on it, and then you'll get two form1's being shown.

What you need to do is:
- Add a public global variable of the form1 type to your form2
- When you create an instance of the new form2 from form1, assign "Me" to that variable - for example, in form1:
Dim frm2 as new Form2
frm2.m_Form1 = Me
- Now on Form two you can mess with form1 as much as you want through that variable.

Hope that helps
UltraMAX2K5
UltraMAX2K5
Got it Alexandre, thanks for your help!
I use a module and works fine:

Module Teste
Public frm1 As Form1
End Module

and then in form1.load ...
Teste.frm1 = Me

then in form2 button1.click ...
frm1.StatusBar1.Text = "SIMPLE TESTE"

now it works great! :)

Thank you (muito obrigado)!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.