Showing posts with label vbprogram. Show all posts
Showing posts with label vbprogram. Show all posts

Monday, 6 June 2016

Registration form example using VB.net




Opening, Closing, and Hiding Forms with Visual Basic .NET

Opening,Showing, Closing, and Hiding Forms with Visual Basic .NET


NOTE-Before you can open (or close) a form, you need to know the specific name of the form you want to open or close. The Solution Explorer window lists the names of all the forms that make up your Visual Basic .NET program, such as a form named frmMain.vb.

Opening a form:

After you know the name of the form that you want to display, you need to use BASIC command to open the form, such as the following:
Dim oForm As FormName
oForm = New FormName()
oForm.Show()
oForm = Nothing

Hiding a form

If you want to temporarily make a form disappear, you can use the magic Hide command, such as:
FormName.Hide()

Showing a form

After you've hidden a form, you'll eventually want to make it visible again by using the Show command, such as:
FormName.Show()

Closing a form

Hiding a form just tucks it out of sight, but the form is still loaded in the computer's memory. To clear a form out of memory, you need to use the Close command, such as:
FormName.Close()


How to: Add Windows Forms to a Project(Inserting a Form into a Project)

Inserting a Form into a Project


To insert a form into your project

  1. From Class View, select the project to which you want to add the form, and click the right mouse button.
  2. From the shortcut menu, click Add and then click Add Class.
    If the New Form command is not available, your project may be based on the Active Template Library (ATL). To add a form to an ATL project, you must specify certain settings when first creating the project.
  3. From the MFC folder, click MFC Class.
  4. Using the MFC Class Wizard, make the new class derive from CFormView.
Visual C++ adds the form to your application, opening it inside the Dialog editor so that you can begin adding controls and working on its overall design.

Sources: https://msdn.microsoft.com/en-us/library/fhxbke21.aspx

Sunday, 5 June 2016

Simple Form for adding the leaves of an Employee




How to: Delete records from SQL table in VB.Net

How to: Delete records from SQL table in VB.Net 




Code to delete a record from SQL table using VB.Net is as follows:


Note-
1: Double Click the delete button and copy the following code
2:And also change the server in connection string and the database also

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
        Try
            con.ConnectionString = "Server=.\SQLEXPRESS;Database=Employee Details;Trusted_Connection=True"
            con.Open()
            cmd.Connection = con
            cmd.CommandText = "Delete From emp_det where emp_id like @emp_id"

            cmd.Parameters.Add(New SqlParameter("@emp_id", TextBox1.Text))
            cmd.ExecuteNonQuery()
            If MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = DialogResult.No Then

                MsgBox("Operation Cancelled")

                Exit Sub

            End If
        Catch ex As Exception
            MessageBox.Show("Error while deleting record on table..." & ex.Message, "Delete Records")

        Finally

            con.Close()

        End Try

    End Sub