Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Course: Visual Programming (DCSA 1304)

Lab 01:
Creating, saving and running a simple visual basic project.
 Creating a new Project: Visual basic 2008
Click File Manu Click New project Or Ctrl + N
That gives a name of your Project & Ok
Now you see a new project in your Windrow.

 Save a new Project: Visual basic 2008

 Click File Manu Click Save or Ctrl + S

than you see the blew Picture Save Project

That gives a name of your Project & Ok

 Run a new Project: Visual basic 2008


Your Firstly must sure your project all items is save than you run your Project
Which you make

Then you ClickDebugStart Debugging or F5 Button


Lab 02: Customizing forms and use of basic controls (Textbox, Label, Command
Button, Checkbox, Radio Button, List box).

Text box Enables you to, in a rectangular box, view, type, or edit text
or data that is bound to a cell. A text box can also be a static
text field that presents read-only information.

Label Identifies the purpose of a cell or text box, or displays


descriptive text (such as titles, captions, pictures) or brief
instructions.

Command Runs a macro that performs an action when a user clicks it. A
button command button is also referred to as a push button.

Check box Turns on or off a value that indicates an opposite and


unambiguous choice. You can select more than one check
box on a worksheet or in a group box. A check box can have
one of three states: selected (turned on), cleared (turned
off), and mixed, meaning a combination of on and off states
(as in a multiple selection).
Radio Allows a single choice within a limited set of mutually
button exclusive choices; a Radio button is usually contained in a
group box or a frame. A Radio button can have one of three
states: selected (turned on), cleared (turned off), and mixed,
meaning a combination of on and off states (as in a multiple
selection).
List box Displays a list of one or more items of text from which a user
can choose. Use a list box for displaying large numbers of
choices that vary in number or content. There are three
types of list boxes:

A single-selection list box enables only one choice. In this


case, a list box resembles a group of option buttons, except
that a list box can handle a large number of items more
efficiently.
A multiple selection list box enables either one choice or
contiguous (adjacent) choices.
An extended-selection list box enables one choice,
contiguous choices, and noncontiguous (or disjointed)
choices.
Lab 03: Use of tree view control, Trackbar, Timer, Image, Msg Box, Input box,
Mathematical Operation, Creating Menu.

The TreeView control is used to display


hierarchical representations of items similar
to the ways the files and folders are
Tree
displayed in the left pane of the Windows
View Control
Explorer. Each node may contain one or more
child nodes.

The TrackBar control allows you to drag a


pointer along a bar to select
a numeric value.
The control's Value, Minimum, Maximum,
and Tick Frequency properties
TrackBar are integer values, so the TrackBar control
is not ideal for letting the user select a non-
integral value such as 5.34. Its Scroll event
fires when the user changes the control's
value interactively

You can change the properties of Timer as


needed, right click on it and click on
Properties: If you set Enabled to True, Timer
will start ticking as soon as the form loads.
Timer
Default is False.
Interval: as described: The frequency of
Elapsed events in milliseconds. 1000 = 1
second.
Displays a message in a dialog box, waits for
the user to click a button, and then returns
Msg Box
an integer indicating which button the user
clicked.
An input box is a specially designed dialog
box that allows the programmer to request a
value from the user and use that value as
Input box, necessary. An input box displays a title, a
message to indicate the requested value,
a text box for the user, and two buttons: OK
and Cancel. Here is an example:
Lab 04: a) String manipulation
The String class of the .NET framework provides many built-in methods to facilitate the comparison
and manipulation of strings. It is now a trivial matter to get data about a string, or to create new strings
by manipulating current strings. The Visual Basic .NET language also has inherent methods that
duplicate many of these functionalities.
Types of String Manipulation Methods
In this section you will read about several different ways to analyze and manipulate your strings. Some
of the methods are a part of the Visual Basic language, and others are inherent in the String class.
Visual Basic .NET methods are used as inherent functions of the language. They may be used without
qualification in your code. The following example shows typical use of a Visual Basic .NET string-
manipulation command:

Dim aString As String = "SomeString"


Dim bString As String
bString = Mid(aString, 3, 3)

In this example, the Mid function performs a direct operation on aString and assigns the value
to bString. You can also manipulate strings with the methods of the String class. There are two types of
methods in String: shared methods and instance methods.
A shared method is a method that stems from the String class itself and does not require an instance of
that class to work. These methods can be qualified with the name of the class (String) rather than with
an instance of the String class. For example:

Dim aString As String


bString = String.Copy("A literal string")

In the preceding example, the String.Copy method is a static method, which acts upon an expression it
is given and assigns the resulting value to bString.
Instance methods, by contrast, stem from a particular instance of String and must be qualified with the
instance name. For example:

Dim aString As String = "A String"


Dim bString As String
bString = aString.SubString(2,6) ' bString = "String"

In this example, the SubString method is a method of the instance of String (that is, aString). It


performs an operation on aStringand assigns that value to bString.

Lab 05: Use of Loop


Visual Basic loop structures allow you to run one or more lines of code repetitively. You can repeat the
statements in a loop structure until a condition is True, until a condition is False, a specified number of
times, or once for each element in a collection.
The following illustration shows a loop structure that runs a set of statements until a condition becomes
true.
Running a set of statements until a condition becomes true
While Loops
The While...End While construction runs a set of statements as long as the condition specified in
the While statement is True. For more information, see While...End While Statement.
Do Loops
The Do...Loop construction allows you to test a condition at either the beginning or the end of a loop
structure. You can also specify whether to repeat the loop while the condition remains True or until it
becomes True. For more information, see Do...Loop Statement.
For Loops
The For...Next construction performs the loop a set number of times. It uses a loop control variable,
also called a counter, to keep track of the repetitions. You specify the starting and ending values for this
counter, and you can optionally specify the amount by which it increases from one repetition to the
next. For more information, see For...Next Statement.
For Each Loops
The For Each...Next construction runs a set of statements once for each element in a collection. You
specify the loop control variable, but you do not have to determine starting or ending values for it. For
more information, see For Each...Next Statement.

Lab 06: Creating Report.

All Crystal Reports programming samples in this tutorials is based on the following database


(crystaldb) . Please take a look at the database structure before you start this tutorial - Click here to
see Database Structure .

Open Visual Studio .NET and select a new Visual Basic .NET Project.

Create a new Crystal Reports for Product table from the above database crystalDB. The Product Table
has three fields (Product_id,Product_name,Product_price) and we are showing the whole table data in
the Crystal Reports. From main menu in Visual Studio select PROJECT-->Add New Item. Then Add
New Item dialogue will appear and select Crystal Reports from the dialogue box.
 Select Report type from Crystal Reports gallery.
Accept the default settings and click OK.
 Next step is to select the appropriate connection to your database.
Here we are going to select OLEDB connection for SQL Server
Select OLE DB (ADO) from Create New Connection.
 Next screen is the SQL Server authentication screen .
 Select your Sql Server name , enter userid , password and
select your Database Name . Click next , Then the screen shows
OLE DB Property values , leave it as it is , and click finish.
 Then you will get your Server name under OLEDB Connection
from there select database name (Crystaldb) and click the tables , then you can see all your
tables from your database. From the tables list select Product table to the right side list .
 Click Next Button
 Select all fields from Product table to the right side list.
 Click Finish Button. Then you can see the Crystal Reports designer window. You can arrange the
design according your requirements. Your screen looks like the following picture.

Now the designing part is over and the next step is to call the created Crystal Reports in VB.NET
through Crystal Reports Viewer control.

Select the default form (Form1.vb) you created in VB.NET and drag a button
and CrystalReportViewer control to your form.

Select Form's source code view and put the code on top
Imports CrystalDecisions.CrystalReports.Engine
Put the following source code in the button click event
The Crystal Reports is in your project location, there you can see CrystalReport1.rpt. So give the full
path name of report here. 

After you run the source code you will get the report like this. 

You might also like