Results 1 to 6 of 6

Thread: Form Help in MS Visual Basic 2008!

  1. #1
    Join Date
    Aug 2006
    Posts
    121

    Form Help in MS Visual Basic 2008!

    I am new to the MS Visual Basic 2008. I have just started doing programs in Visual Basic. I had created 3 forms. I had a button to take me to the second form as well as third form. I have hidden the first form, to get the rid of it. I need your help in updating the form in MS Visual Basic 2008. After hiding the first form, how can I show the form again.? Also is there a way that after opening the first form, that I can just switch the control of the program to a new form?? Please help me by providing some information or the code.!
    Whats my name again? I spend so much time looking at code i fogot my own name ahhh!

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Form Help in MS Visual Basic 2008!

    I think that the following code is pretty simpler way to catch the form close event :
    Code:
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If UnloadMode = vbFormControlMenu Or UnloadMode = 1 Then
                  'the X has been clicked or the user has pressed Alt+F4
                  Cancel = True
              End If
          End Sub

  3. #3
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Form Help in MS Visual Basic 2008!

    According to me if you want to show the first form again after it is hidden, you can do that by simply putting Form1.Show() under whatever event you want the form to be shown. Also you can use the following code if you want to open a form in visual basic and then to close the previous form. Here is the code for that
    Code:
    Form2.Show
    Unload Form1

  4. #4
    Join Date
    Nov 2008
    Posts
    1,192

    Re: Form Help in MS Visual Basic 2008!

    Also if you want to show the another form you can use the following coding :
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    Dim form2 As New Form2
    form2.Show()
    
    End Sub
    By using this coding you can open the Form2 when you click the button for which you are using this code. But for that declare a object for the second form.

  5. #5
    Join Date
    Nov 2008
    Posts
    996

    Re: Form Help in MS Visual Basic 2008!

    You also want to switch the control of the program to a new form, after opening the first form. For that you must first go to the Project menu, then select [project name] Properties. You will have to change the Shutdown mode to "When last form closes", which would be present under the Application tab. If this option is Grayed out, then you will have to check the option "Enable Application Framework". After checking this option, you will able to select that option. Then put Me.Close() where ever you are using Me.Hide(), and the form will now close instead of hiding, without ending your whole program. Also you will have to use Application.Exit() when you want to close your program.

  6. #6
    Join Date
    Mar 2008
    Posts
    349

    Re: Form Help in MS Visual Basic 2008!

    You can also use the following code for Hiding and Unhiding the forms.
    Code:
    Private Sub Command1_Click()
              If opt(0).Value = True Then
                  SetXState Me, True   'enable the X button
              ElseIf opt(1).Value = True Then
                  SetXState Me, False  'disable the X button
              End If
          End Sub

Similar Threads

  1. Replies: 2
    Last Post: 02-05-2011, 07:06 AM
  2. help on visual basic 2008
    By gladys_ny in forum Software Development
    Replies: 1
    Last Post: 18-03-2011, 04:25 AM
  3. Closing out a form in Visual Basic
    By Adel123 in forum Software Development
    Replies: 3
    Last Post: 31-08-2009, 04:56 PM
  4. Visual basic crashes when viewing form
    By Bandish 555 in forum Windows Software
    Replies: 3
    Last Post: 23-06-2009, 06:04 PM
  5. simple login form in visual basic 6?
    By hariharan_00 in forum Software Development
    Replies: 3
    Last Post: 28-10-2006, 08:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,712,515.09257 seconds with 17 queries