Micheltje16
01-11-2004, 08:08 AM
How can i open a new form with .net? In vb6 it's just frmSomeName.Show but that doesn't work in .net.
Anyone?
Anyone?
[.net] Problem with opening formsMicheltje16 01-11-2004, 08:08 AM How can i open a new form with .net? In vb6 it's just frmSomeName.Show but that doesn't work in .net. Anyone? Iceplug 01-11-2004, 08:10 AM Dim F As Form = New frmSomeName F.Show() :) Micheltje16 01-11-2004, 08:30 AM Dim F As Form = New frmSomeName F.Show() :) Do you also know how to close a form? Unload(frm2) doesn't seem to work either. Thanks Iceplug 01-11-2004, 08:33 AM f.Close() or Me.Close() will close the form. :) Micheltje16 01-11-2004, 08:40 AM f.Close() or Me.Close() will close the form. :) Private Sub PiOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PiOK.Click 'variablen declaren Dim frm2 As Form = New VPF1() frm2.SCOpenen.Enabled = True It doesn't recognize the SCOpenen in frm2. When i use frm2.Show It opens a copy of form1 and doesn't change anything in the form that's actualy there. I tried to let it change a label but it didn't do anything Iceplug 01-11-2004, 08:47 AM Try Dim frm2 As VPF1 = New VPF1() Make sure that VPF1 is the actual name that you give to the form (the name of the form variable there 'frm2' can be anything). :) reboot 01-11-2004, 09:23 AM It doesn't recognize the SCOpenen in frm2. When i use frm2.Show It opens a copy of form1 and doesn't change anything in the form that's actualy there. I tried to let it change a label but it didn't do anything VB.Net is quite different from VB6. Forms are not Public in your project and you can't set the values of things on one Form from another Form directly like you could in VB6. Micheltje16 01-11-2004, 09:38 AM Try Dim frm2 As VPF1 = New VPF1() Make sure that VPF1 is the actual name that you give to the form (the name of the form variable there 'frm2' can be anything). :) This is standing on form 1 called VPF1 on this form i have a menu Public Class VPF1 Inherits System.Windows.Forms.Form Private Sub SCInstellen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SCInstellen.Click Dim oCommSetup As New CommSetup() oCommSetup.ShowDialog() oCommSetup = Nothing End Sub Private Sub SCOpenen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SCOpenen.Click SCSluiten.Enabled = True ' sluiten mogelijk SCInstellen.Enabled = False ' poort instellen niet meer mogelijk SCOpenen.Enabled = False ' om niet twee maal te kunnen openen End Sub Private Sub SCSluiten_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SCSluiten.Click SCOpenen.Enabled = False ' Openen niet meer mogelijk SCInstellen.Enabled = True ' poort instellen mogelijk men moet nu eerst weer OK drukken ? End Sub the second form called Public Class CommSetup Inherits System.Windows.Forms.Form ' Declare necessary class variables. Private CommPort As New Rs232() Private CPort As Integer = 1 Private CBaud As Integer = 9600 Private CPar As Integer = 0 '0=NONE 1=ODD 2=EVEN 3=MARK Private CDataB As Integer = 8 Private CStopB As Integer = 1 Private Sub PiOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PiOK.Click If PGCom1.Checked Then CPort = 1 If PGCom2.Checked Then CPort = 2 If PGCom3.Checked Then CPort = 3 If BRG4800.Checked Then CBaud = 4800 If BRG9600.Checked Then CBaud = 9600 If BRG19200.Checked Then CBaud = 19200 If PGNone.Checked Then CPar = 0 If PGOdd.Checked Then CPar = 1 If PGEven.Checked Then CPar = 2 If DBG6.Checked Then CDataB = 6 If DBG7.Checked Then CDataB = 7 If DBG8.Checked Then CDataB = 8 If SBG1.Checked Then CStopB = 1 If SBG15.Checked Then CStopB = 15 If SBG2.Checked Then CStopB = 2 'this is what i want to use here !!! SCOpenen.Enabled = True Me.Close() End Sub End Class Maybe u see the problem reboot 01-11-2004, 09:41 AM I just explained the problem. The first form can't see the members of the second form. Iceplug 01-11-2004, 05:21 PM You are going to have to supply a reference to VPF1 via a Public Subroutine, like the 'New' subroutine for CommSetUp. You need to declare an extra Sub New(ByRef F As Form) and then, when you set CommSetUp to a new instance, you can pass the VPF1 in as an argument. From there, you can store it in a variable and access it from there. :) |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum