Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to close directly a form

Status
Not open for further replies.

curiousvbnet

Programmer
Apr 6, 2007
40
FR
Hi,

I have created a form and i want to close it just after i click on the cross at the top right of the form but i have to click twice to close it well.
Could you explain me why.

Is there something to do at the properties level?

Here is the associated code to this form.


Code:
Public Class candidat_descripteur 
    Inherits System.Windows.Forms.Form 

Private m_objConn As SqlConnection 
    Private objDS6 As DataSet 
    Private objDA6 As SqlDataAdapter 



      [blue] Private Sub Enreg_cd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Enreg_cd.Click [/blue]
        Dim strInsert_cd As String, objInsertNew_cd As SqlCommand, strSQLTERMES_Cd As String, drTerme As DataRow 
        Dim termecd_existe As Boolean 
        strSQLTERMES_Cd = "SELECT Lib_CD from CANDIDAT_DESCRIPTEUR" 

      [green]  strInsert_cd = "INSERT into CANDIDAT_DESCRIPTEUR(Lib_CD) values ('" 
        strInsert_cd &= Replace(txtbox_cd.Text, "'", "''") & "')" [/green]

         
        'il faut verifier si ce terme n'existe pas déjà dans la table des candidats descripteurs 
        objDS6 = New DataSet 
        objDA6 = New SqlDataAdapter(strSQLTERMES_Cd, m_objConn) 
        objDA6.Fill(objDS6, "TERMES_CD") 

        For Each drTerme In objDS6.Tables("TERMES_CD").Rows 
            Dim strLibelle5, strLibelle6 As String 

                       strLibelle5 = Replace(txtbox_cd.Text, " ", "") 
                       strLibelle6 = Replace(strLibelle5, "-", "") 

                       Dim libterme5, libterme6 As String 

            libterme5 = Replace((CType(drTerme.Item("Lib_CD"), String).ToUpper), " ", "") 
            libterme6 = Replace(libterme5, "-", "") 
            
            If SansAccent(strLibelle6.ToUpper) = SansAccent(libterme6) Then 
               termecd_existe = True Exit For 
                Exit Sub 

            End If 
        Next 

        If termecd_existe = False Then 
   m_objConn.Open() 
            [green]objInsertNew_cd = New SqlCommand(strInsert_cd, m_objConn) 
            objInsertNew_cd.ExecuteNonQuery() m_objConn.Close() [/green]

                       txtbox_cd.Focus() 


        End If 

    End Sub 



Private Sub Annul_saisie_CD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Annul_saisie_CD.Click 

               txtbox_cd.Text = "" 
End Sub



Thanks a lot for your help

Regards.
Nathalie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top