Text box: In order to display or accept user input in the form of text like name, customer ID, ETC., Visual basic provides you with this controls. It is used to display text and allows the user to edit the data in the box. A text box control is also called an edit field or edit control. It displays the information entered at design time, entered by the user, or assigned to the control in code at run time. Command button: Creates a button that the user can choose to carry out a command. The user will click on this button and the computer will perform the task associated with the button. Activity does not stop with the invoice that you have generated. A copy may have to be sent to the commercial tax department, the credit card company, the head office, and so on.
Label box: It allows you to display text that you don’t want the user to change, such as a caption under a graphic. When you want to print the voices, you need to know if the customer is going to pay by cash or toque, or credit card. This means that the billing clerk has to select one from the various options available. For this Visual basic has the option button control. Check box: Creates a box that the user can easily choose to indicate if something is true or false, or to display multiple choices when the user can choose more than one. There are many more controls that Visual basic provides that may not be used in the immediate context. Let us take a look at the other controls that are part of the standard set of controls available on the toolbox.
Combo box: The user can either choose an item from the list or enter a value in the text box. The new value entered can be added to the existing data. The list box and the combo box display data usually from a database. In order to access data and to manipulate data in a database like access, SQL server, etc. Visual basic provides a control called the data control. Image control: This is very similar to the pictures box control. Images displayed in an image control can only be decorative and use fewer resources than a pictures box.
 Moving from one drive to another : The DriveListBox  Moving from one directory to another : DirListBox  List file(s) in a dictionary : FileListBox
 The DriveListBox control: This is a drop-down list box that will display the list of drives on your computer. It gets all information from the operating system and allows the user to select a drive of the choice. Selecting a particular drive records a change in the Drive property of the DriveListBox.  The DirListBox control: A drop-down list box that displays a hierarchical list of directories in the current drive.  The FileListBox: Displays all files in the current Directory or Folder. Allows users to set up search criteria for files. These three controls used together can create an elegant interface that will allow the user to locate a file on his computer without any sweat.
Add the Common Dialog control to your toolbox by Right clicking on the toolbox and selecting ‘Components’ from the pop-up menu. Next select ‘Microsoft common dialog control 6.0 from the list of components. You will see this as a control on your toolbox. Draw it on your form. Please note that this control does not have an interface that the user will see and work on. During runtime it is not visible. However
The common dialog box control made our life easier by giving us a simple and easy way to provide the necessary interface to the user. We were able to create a small application that would allow the user to create a new file or open an existing file, add text to it, save the changes and print the contents of the file as well.
The tree view control is a very interesting control to work with. With this control you can display the data as a hierarchy. The windows explorer is built around a tree view control. It displays the drives, directories, subdirectories and files in the form of a hierarchy. You can use the same control to display the data from a database. For example, you can display the list of customers, the invoice no and date for each customer, and for each invoice the items therein and so forth.
Working with the tree view control: Draw a Tree View control on your form. Add the following code to the form load event. Private Sub Form_Load() Dim NewNode As Node Set NewNode = TreeView1.Nodes.Add(, , ”c”, ”customer”) Set NewNode = TreeView1.Nodes.Add(“c” , tvwchild , “child1”, “Customer_Code”) Set NewNode = TreeView1.Nodes.Add(“c” , tvwchild , “child2”, “Customer_Name”) Set NewNode = TreeView1.Nodes.Add(“c” , tvwchild , “child3”, “Customer_City”) End Sub
What is database? A database can be defined as a collection of records stored in tables. It has a set of rules and tools to manage these records. There are different type of data bases, each with it’s own format. the most commonly known data base type are:  Relational database  Network model  Hierarchical model
user 1’s view user 2’s view Supplier Name Address Amount Due Supplier Name Address Physical view
 The database grid control display fields from a record set object as a series of rows and columns, and enables manipulation of this data.  The data aware DBgrid control is like an enhanced grid control. Once the properties are set, gets populated automatically with the data from the record set object.  You only need to fix the number of columns. The total number of rows is indeterminate. A DB Grid control can have as many rows as the system resources can support and about 1700 columns.  Lets us see the DB Grid in action: start a new project. On the form add the following control  One data control  One DB grid control
 If you don't have the DB grid control, as part of your tool box, right click on the tool box. Select components from the were pop-up menu. From the list displayed there after, click on DB grid control. click on OK you have it on your toolbox.  Set the properties for the controls as follows Data control Data base sources: C:/VB/Bibli.mdb Records sources: Publishers DB Grid control data sources: data1
 To open a data base, we have to use the open database method. This method opens a specified database in a workspace object and return a reference to the data base object that represents it.  Syntax: Set database = workspace.OpenDatabase (dbname,options,read- only,connect) The OpenDatabase method syntax has three parts.  Databsae  Workspace  Dbname  Options  Read-only  Connect
Visual basic programming

Visual basic programming

  • 3.
    Text box: In orderto display or accept user input in the form of text like name, customer ID, ETC., Visual basic provides you with this controls. It is used to display text and allows the user to edit the data in the box. A text box control is also called an edit field or edit control. It displays the information entered at design time, entered by the user, or assigned to the control in code at run time. Command button: Creates a button that the user can choose to carry out a command. The user will click on this button and the computer will perform the task associated with the button. Activity does not stop with the invoice that you have generated. A copy may have to be sent to the commercial tax department, the credit card company, the head office, and so on.
  • 4.
    Label box: It allowsyou to display text that you don’t want the user to change, such as a caption under a graphic. When you want to print the voices, you need to know if the customer is going to pay by cash or toque, or credit card. This means that the billing clerk has to select one from the various options available. For this Visual basic has the option button control. Check box: Creates a box that the user can easily choose to indicate if something is true or false, or to display multiple choices when the user can choose more than one. There are many more controls that Visual basic provides that may not be used in the immediate context. Let us take a look at the other controls that are part of the standard set of controls available on the toolbox.
  • 5.
    Combo box: The usercan either choose an item from the list or enter a value in the text box. The new value entered can be added to the existing data. The list box and the combo box display data usually from a database. In order to access data and to manipulate data in a database like access, SQL server, etc. Visual basic provides a control called the data control. Image control: This is very similar to the pictures box control. Images displayed in an image control can only be decorative and use fewer resources than a pictures box.
  • 7.
     Moving fromone drive to another : The DriveListBox  Moving from one directory to another : DirListBox  List file(s) in a dictionary : FileListBox
  • 8.
     The DriveListBoxcontrol: This is a drop-down list box that will display the list of drives on your computer. It gets all information from the operating system and allows the user to select a drive of the choice. Selecting a particular drive records a change in the Drive property of the DriveListBox.  The DirListBox control: A drop-down list box that displays a hierarchical list of directories in the current drive.  The FileListBox: Displays all files in the current Directory or Folder. Allows users to set up search criteria for files. These three controls used together can create an elegant interface that will allow the user to locate a file on his computer without any sweat.
  • 9.
    Add the CommonDialog control to your toolbox by Right clicking on the toolbox and selecting ‘Components’ from the pop-up menu. Next select ‘Microsoft common dialog control 6.0 from the list of components. You will see this as a control on your toolbox. Draw it on your form. Please note that this control does not have an interface that the user will see and work on. During runtime it is not visible. However
  • 10.
    The common dialogbox control made our life easier by giving us a simple and easy way to provide the necessary interface to the user. We were able to create a small application that would allow the user to create a new file or open an existing file, add text to it, save the changes and print the contents of the file as well.
  • 11.
    The tree viewcontrol is a very interesting control to work with. With this control you can display the data as a hierarchy. The windows explorer is built around a tree view control. It displays the drives, directories, subdirectories and files in the form of a hierarchy. You can use the same control to display the data from a database. For example, you can display the list of customers, the invoice no and date for each customer, and for each invoice the items therein and so forth.
  • 12.
    Working with thetree view control: Draw a Tree View control on your form. Add the following code to the form load event. Private Sub Form_Load() Dim NewNode As Node Set NewNode = TreeView1.Nodes.Add(, , ”c”, ”customer”) Set NewNode = TreeView1.Nodes.Add(“c” , tvwchild , “child1”, “Customer_Code”) Set NewNode = TreeView1.Nodes.Add(“c” , tvwchild , “child2”, “Customer_Name”) Set NewNode = TreeView1.Nodes.Add(“c” , tvwchild , “child3”, “Customer_City”) End Sub
  • 14.
    What is database? Adatabase can be defined as a collection of records stored in tables. It has a set of rules and tools to manage these records. There are different type of data bases, each with it’s own format. the most commonly known data base type are:  Relational database  Network model  Hierarchical model
  • 15.
    user 1’s viewuser 2’s view Supplier Name Address Amount Due Supplier Name Address Physical view
  • 16.
     The databasegrid control display fields from a record set object as a series of rows and columns, and enables manipulation of this data.  The data aware DBgrid control is like an enhanced grid control. Once the properties are set, gets populated automatically with the data from the record set object.  You only need to fix the number of columns. The total number of rows is indeterminate. A DB Grid control can have as many rows as the system resources can support and about 1700 columns.  Lets us see the DB Grid in action: start a new project. On the form add the following control  One data control  One DB grid control
  • 17.
     If youdon't have the DB grid control, as part of your tool box, right click on the tool box. Select components from the were pop-up menu. From the list displayed there after, click on DB grid control. click on OK you have it on your toolbox.  Set the properties for the controls as follows Data control Data base sources: C:/VB/Bibli.mdb Records sources: Publishers DB Grid control data sources: data1
  • 18.
     To opena data base, we have to use the open database method. This method opens a specified database in a workspace object and return a reference to the data base object that represents it.  Syntax: Set database = workspace.OpenDatabase (dbname,options,read- only,connect) The OpenDatabase method syntax has three parts.  Databsae  Workspace  Dbname  Options  Read-only  Connect