Results 1 to 2 of 2

Thread: Show Form Once Time..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2011
    Posts
    85

    Show Form Once Time..

    Hi guys.

    I want when I click a button , it show form2 but if i click it again , it don't show form2...

    Can help me ?

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,714

    Re: Show Form Once Time..

    One method is to set a private form level variable as shown below. After the form is shown the variable is set to false which prevents the form from being shown again.

    Code:
    Private ShowForm2 As Boolean = True
    Private Sub cmdShowForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShowForm.Click
    
        If ShowForm2 Then
            Dim f As New Form2
    
            Try
                f.ShowDialog()
            Finally
                f.Dispose()
            End Try
            ShowForm2 = False
        End If
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width