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 let a form opened

Status
Not open for further replies.

curiousvbnet

Programmer
Apr 6, 2007
40
FR
Hi,

In the form 'candidat_desxripteur' i permit a user to keybord a new term and to insert it in the 'descriptors terms' table.

I can see that after the user has finished to enter the term text in the textbox called "txtbox_cd", the form closed automatically whereas i want to let it the possibility to close the form when he wants to and to insert the number of descriptors term he wants.
How can i prevent from closing automatically the form ?

Thanks alot for all your help.

Best regards.
Nathalie
 
Hi, here is the code of this form

Code:
Imports System.Xml
Imports Application_Windows_Thesaurus.TreeView_MT_GEN_SPE_ASSOCIES


Public Class candidat_descripteur
    Inherits System.Windows.Forms.Form
 Private m_objConn As SqlConnection
    Private objDS6 As DataSet
    Private objDA6 As SqlDataAdapter



    Public WriteOnly Property Connection() As SqlConnection
        Set(ByVal Value As SqlConnection)
            m_objConn = Value
        End Set
    End Property
   [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

       [green] strSQLTERMES_Cd = "SELECT Lib_CD from CANDIDAT_DESCRIPTEUR"

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

        

        'we verify the term does not already exist in the candidat_descripteur table       
        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
               [blue] termecd_existe = True[/blue]
                MessageBox.Show("ce terme candidat descripteur existe déjà dans la table des candidats descripteurs, vous ne pouvez pas le réinsérer", "insertion d'un terme candidat descripteur", MessageBoxButtons.OK)
                txtbox_cd.Text = ""
                Exit For
                Exit Sub

            End If
        Next

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

            MessageBox.Show("le terme candidat descripteur '" & txtbox_cd.Text.TrimEnd & "'  a bien été ajouté à la table des termes candidats descripteurs", "ajout d'un terme candidat descripteur", MessageBoxButtons.OK)
            txtbox_cd.Text = ""


        End If

    End Sub
 
Maybe you've set the dialogresult property of the Enreg_cd button to something else than NONE therefore the form closes after the button is clicked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top