Solved

VB.net > Making another form active

Posted on 2004-08-28
1
286 Views
Last Modified: 2010-04-17
I just started my 5th programming corse and for the life of me i cant find what im looking for. im probably just screwing up sintax or somehting.

Basically, i have 1 solution with 1 project and 2 forms in that project.

if i have form1 which has a button1 in it and a form 2

Form 1 is what executes first when the program starts running.

But what code do i need to have in the button1's onclick Subroutine that will cause form2 to become active??

all i have been able to find is how do to this in VB.6.0 by going form2.visible = true, but since form2 doesn't appear to have that property for it's control, i assume that was one of the (many) rivision points from VB 6 to VB. NET...

sumarized question:

what line of code will cause form2 to pop up infront of form1; AND if i have a characterbla.vb class file instanciated with characterBla variableName = new characterBla, should i be able to access that object and it's variables from form2 with variableName.whatEver() ??? or is there something i need to prefix?

asdlkf
0
Comment
Question by:asdlkf
1 Comment
 
LVL 14

Accepted Solution

by:
Farzad Akbarnejad earned 500 total points
ID: 11924707
Hi,

Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim frm2 As Form2

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(112, 80)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(112, 128)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(80, 24)
        Me.Button2.TabIndex = 1
        Me.Button2.Text = "Button2"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 271)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        frm2 = New Form2

        frm2.Show()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        frm2.BringToFront()
    End Sub
End Class


-FA
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to use laptop or pad camera in vb.net windows application 2 103
Generate Unique ID in VB.NET 21 99
Hive vs Impla in Hadoop 1 71
programming a polycom voip phone 3 52
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question