Top-Rated Free Essay

Visual Basic

Topics: Graphical user interface / Pages: 9 (2145 words) / Published: Jun 19th, 2013
SRI SAI UNIVERSITY PALAMPUR HP

[pic]

SUBMITTED TO : SUBMITTED BY:
ER. SAURABH SHARMA VED BHUSHAN

INDEX:

|Sr. No |Experiment |Date |Remarks |
|1 |The Integrated Development Environment |13/08/12 | |
|2 |Write a Program in VB to display welcome in visual basic on a Label.|13/08/12 | |
|3 |Write a program in VB to find out the Area of Circle. |13/08/12 | |
|4 |Write a program in VB to display your name on a form. |27/08/12 | |
|5 |Write a program to change a color of text written in text box of the|27/08/12 | |
| |form. | | |
|6 |Write a program in VB to create the calculator to perform the |03/09/12 | |
| |arithmetic operation. | | |
|7 |Write a program to enter the marks of students in four different |03/09/12 | |
| |subjects and calculate the total entered marks and percentage marks | | |
| |and display the corresponding grades. | | |
|8 |Write a program to find the larger number between three numbers. |03/09/12 | |
|9 |Write a program to find a person is teenager. |03/09/12 | |
|10 |Write a program in VB to sum and count. |10/09/12 | |
|11 |Write a program in VB to multilingual hello. |09/10/12 | |
|12 |Write a program in VB to find number larger between two numbers. |16/10/12 | |
|13 |Write a program in VB to show current date and current time. |29/11/12 | |
|14 |write a program in vb to find the factorial. |30/11/12 | |
|15 |Write a program in V.B to show different color using different case |1/12/12 | |
| |statement. | | |

Experiment1:

Title: - The Integrated Development Environment (IDE)

Different files of VB which has been selected for programming. We select standard EXE file of VB for the programming.

[pic]

IDE:

One of the most significant changes in Visual Basic 6.0 is the Integrated Development Environment (IDE). IDE is a term commonly used in the programming world to describe the interface and environment that we use to create our applications. It is called integrated because we can access virtually all of the development tools that we need from one screen called an interface. The IDE is also commonly referred to as the design environment, or the program.

[pic]

The Main Window consists of the title bar, menu bar, and toolbar. The Title bar indicates the project name, the current Visual Basic operating Mode and the current form. The menu bar has drop-down menus from which you control the operation of the Visual Basic environment. The toolbar has buttons that provide shortcuts to some of the menu options. The main window also shows the location of the current form relative to the upper left corner of the screen (measured in twips) and the width and length of the current form.

TOOLBAR:-

A toolbar is a bar that displays icons for commonly used tasks. The standard toolbar of Visual Basic displays icons for the most frequently used commands in Visual Basic.

[pic]

FORM WINDOW:-

The Form Window is central to developing Visual Basic applications. It is where you draw your application.

[pic]

TOOLBOX:-

The Toolbox is the selection menu for controls used in your application.

[pic]

PROPERTIES WINDOW:-

The Properties Window is used to establish initial property values for objects. The drop-down box at the top of the window lists all objects in the current form. Two views are available: Alphabetic and Categorized. Under this box are the available properties for the currently selected object.

[pic]

FORM LAYOUT WINDOW:-

The Form Layout Window shows where (upon program execution) your form will be displayed relative to your monitor’s screen.

[pic]

PROJECT WINDOW:-

The Project Window displays a list of all forms and modules making up your application. You can also obtain a view of the Form or Code windows (window containing the actual basic coding) from the Project window.

[pic]

Experiment 2:

Title- Write a program to display a message on a label?

Methodology-

|Object |Property |Default |Customized |
|Label |Caption |Label1 |Blank |
| |Font size |8 |14 |
| |Font style |MS Sans Serif |Times New Roman |
|Command button 1 |Caption |Command1 |Display |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |
|Command button 2 |Caption |Command 2 |Exit |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |

Graphical user interface:

[pic]

CODE-

Private Sub Command1_Click()

Label1.Caption = "WELCOME TO SSU "

End Sub

Private Sub Command2_Click()

End

End Sub

Output-

[pic]

Experiment 3:

Title- Write a program in V.B to find out area of a circle?

Methodology

|Object |Property |Default |Customized |
|Label 1 |Caption |Label1 |Radius |
| |Font size |8 |14 |
| |Font style |MS Sans Serif |Times New Roman |
|Label 2 |Caption |Label2 |Area |
| |Font size |8 |14 |
| |Font style |MS Sans Serif |Times New Roman |
|Textbox1 |Caption |Text1 |Blank |
|Textbox2 |Caption |Text2 |Blank |
|Commandbutton1 |Caption |Command1 |Calculate |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |
|Commandbutton2 |Caption |Command2 |Exit |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |

Graphical user interface:

[pic]

CODE-

Dim a as Single

Dim b as Single

Private Sub Command1_Click()

a = Val(Text1.Text)

b = 3.142 * a * a

Text2.Text = b

End Sub

Private Sub Command2_Click()

End

End Sub

Output

[pic]

Experiment 4:

Title-Write a program to display your name on the form.

Methodology

|Object |Property |Default |Customized |
|Form |Caption |Form1 |SSU |
| |Font size |8 |14 |
| |Font style |MS Sans Serif |Times New Roman |

Graphical user interface (GUI):

[pic]

Code-

Private Sub Form Load()

Form1.Show

Form1.Print "sudhir"

End Sub

Output-

[pic]

Experiment 5:

Title: Write a program in VB to show current date and time in the text box of the form.

METHODLOGY

|Object |Property |Default |Customized |
|Form 1 |BackColor |Grey |Black |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
|Label1 | | | |
| | | | |
| | | | |
| | | | |
| | | | |
|Label2 | | | |
| |Caption |Form1 |Current date and time |
| |Caption |Label1 |Current date current time |
| |Font style |MS Sens Serif |Times New Roman |
| |Font size |8 |14 |
| |Caption |Label2 |Current time |
| |Font |MS Sens Serif |Times New Roman |
| |Caption |Label3 |Current date |
| |Font |MS Sens Serif |Times New Roman |
| |(Name) |Command1 |Cmdisp |
| | | | |
|Command 1 | | | |
| |Caption |Command1 |Show |
| |Font |MS Sens Serif |Times New Roman |
| |Style |0-Standard |1-Graphical |
|Timer 1 |Enable |True |False |

Graphical user interface (GUI):

[pic]

Coding:

Private Sub Command1_Click()

Text1.Text = Time$

Text2.Text = Date$

End Sub

Private Sub Timer1_Timer()

Text1.Text = Time$

End Sub

Output:

[pic]

Experiment 6:

Title-write a program to create a simple calculator that supports addition, subtraction, multiplication, division and modulus.

Methodology-

|Object |Property |Default |Customized |
|Label1 |Caption |Label1 |Enter the first value |
| |Font size |8 |14 |
| |Font style |MS Sans Serif |Times New Roman |
|Label2 |Caption |Label2 |Enter the second value |
| |Font size |8 |8 |
| |Font style |MS Sans Serif |MS Sans Serif |
|Label3 |Caption |Label3 |Result |
| |Font size |8 |8 |
| |Font style |MS Sans Serif |MS Sans Serif |
|Command button1 |Caption |Command1 |Addition |
| |Style |0-Standard |1-Graphical |
| |Backcolor |Grey |Blue |
|Command button2 |Caption |Command2 |Subtraction |
| |Style |Style |1-Graphical |
| |Backcolor |Backcolor |Blue |
|Command button3 |Caption |Command3 |Multiplication |
| |Style |Style |1-Graphical |
| |Backcolor |Backcolor |Blue |
|Command button4 |Caption |Command4 |Division |
| |Style |Style |1-Graphical |
| |Backcolor |Backcolor |Blue |
|Command button5 |Caption |Command5 |Modulus |
| |Style |Style |1-Graphical |
| |Backcolor |Backcolor |Blue |
|Command button6 |Caption |Command6 |Exit |
| |Style | |1-Graphical |
| |Backcolor | |Blue |
|Textbox1 |Text |Text1 |Blank |
|Textbox2 |Text |Text2 |Blank |
|Textbox3 |Text |Text3 |Blank |

Graphical user interface (GUI):

[pic]

CODE-

Private Sub Command1_Click()

Text3.Text = Val(Text1.Text) + Val(Text2.Text)

End Sub

Private Sub Command2_Click()

Text3.Text = Val(Text1.Text) - Val(Text2.Text)

End Sub

Private Sub Command3_Click()

Text3.Text = Val(Text1.Text) * Val(Text2.Text)

End Sub

Private Sub Command4_Click()

Text3.Text = Val(Text1.Text) / Val(Text2.Text)

End Sub

Private Sub Command5_Click()

Text3.Text = Val(Text1.Text) % Val(Text2.Text)

End Sub

Private Sub Command6_Click()

End

End Sub

Output

[pic]

Experiment 7:

Title- Write a program in V.B to create a report card which includes 4 subjects, total, percentage and grade .

Methodology-

|Objects |Property |Default |Customized |
|Label |Caption |Label1 |BBA 3rd semester |
| |Font size |8 |14 |
| |Font style |MS Sans Serif |Times New Roman |
|Label |Caption |Label2 |Accounts |
|Label |Caption |Label3 |Visual basics |
|Label |Caption |Label4 |Marketing |
|Label |Caption |Label5 |Research |
|Label |Caption |Label6 |Total |
|Label |Caption |Label7 |Percentage |
|Label |Caption |Label8 |Grade |
|Text Box |Text |Text1 |Blank |
|Text Box |Text |Text2 |Blank |
|Text Box |Text |Text3 |Blank |
|Text Box |Text |Text4 |Blank |
|Text Box |Text |Text 5 |Blank |
|Text Box |Text |Text6 |Blank |
|Text Box |Text |Text7 |Blank |
|Command Button |Caption |Command1 |Calculate |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |
|Command Button |Caption |Command2 |Clear |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |
|Command Button |Caption |Command3 |Exit |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |

Graphical user interface (GUI):

[pic]

Code-

Private Sub Command1_Click()

Text5.Text = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text)

Text6.Text = Val(Text5.Text) / 400 * 100

If Text6.Text >= 80 Then

Text7.Text = "merit"

ElseIf marks < 80 And marks > 60 Then

Text7.Text = "First division"

ElseIf marks < 50 And marks > 60 Then

Text7.Text = "second division"

Else

Text7.Text = "fail"

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Text7.Text = ""

End Sub

Private Sub Command3_Click()

End

End Sub

Output-

[pic]

Experiment 8:

Title- Write a program in V.B to find out greatest number in three numbers.

Methodology-

|Object |Property |Default |Customized |
|Label |Caption |Label1 |Enter 1st number |
|Label |Caption |Label2 |Enter 2nd number |
|Label |Caption |Label3 |Enter 3rd number |
|Text box |Text |Text1 |Blank |
|Text box |Text |Text2 |Blank |
|Text box |Text |Text3 |Blank |
|Command Button |Caption |Command1 |Find |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |
|Command Button |Caption |Command2 |Exit |
| |Style |0-Standard |1-Graphical |
| |Back color |Grey |Blue |

Graphical user interface (GUI):

[pic]

Code-

Dim a As Single

Dim b As Single

Dim c As Single

Private Sub Command1_Click()

a = Text1.Text

b = Text2.Text

c = Text3.Text

If (a > b) Then

If (a > c) Then

MsgBox "1st number is greater"

Else

MsgBox "3rd number is greater"

End If

ElseIf (b > c) Then

MsgBox "2nd number is greater"

Else

MsgBox "3rd number is greater"

End If

End Sub

Private Sub Command2_Click()

End

End Sub

Output-

[pic]

[pic]

Experiment 9:

Title- Write a program to find a person is teenager or not

Methodology

|Object |Property |Default |Customized |
|Label |Caption |Label1 |Enter the age of person |
|Text |Text |Text1 | |
|Command button 1 |Caption |Comma nd1 |Display |
| |Style |0-Standard |1-Graphical |
| |Back color |Gray |Blue |
|Command button 2 |Caption |Command2 |Exit |
| |Style |0-Standard |1-Graphical |
| |Back color |Gray |Blue |

Graphical user interface (GUI):

[pic]

Code-

Dim a As Integer

Private Sub Command1_Click()

a = Val(Text1.Text)

If a >= 13 And a a Then

MsgBox "2nd number is greater"

Else

MsgBox "both are equal"

End If

End Sub

Private Sub Form_Load ()

End Sub

Output:

[pic]

[pic]

Experiment 13:

Title- How to change the color of text written in a text box on the form?

Methodology-

|Object |Property |Default |Customized |
|Textbox |Text |Text1 |VED BHUSHANTimes New Roman |
| |Font size |8 | |
| |Font style |MS Sans Serif | |
|Command button 1 |Caption |Command1 |Red |
| |Style |0-Standard |1-Graphical |
| |Back color |grey |Red |
|Command button2 |Caption |Command2 |Green |
| |Style |0-Standard |1-Graphical |
| |Back color |grey |Green |
|Command button3 |Caption |Command3 |Blue |
| |Style |0-Standard |1-Graphical |
| |Back color |grey |Blue |
|Command button4 |Caption |Command4 |Yellow |
| |Style |0-Standard |1-Graphical |
| |Back color |grey |Yellow |

Graphical user interface (GUI):

[pic]

CODE-

Private Sub Command1_Click()

Text1.ForeColor = vbRed

End Sub

Private Sub Command2_Click()

Text1.ForeColor = vbGreen

End Sub

Private Sub Command3_Click()

Text1.ForeColor = vbBlue

End Sub

Private Sub Command4_Click()

Text1.ForeColor = vbYellow

End Sub

Output-

[pic]

EXPERIMENT 14:-

TITTLE:- write a program in vb to find the factorial.

Graphical user interface (GUI):

[pic]

CODING:

Public Function factorial(n As Integer) As Long

Dim i As Integer

factorial = 1

If n < 0 Then

MsgBox ("else try again")

Unload Me

ElseIf (n = 0) Then

Text2.Text = 1

ElseIf n > 0 Then

For i = 1 To n

factorial = factorial * i

Next i

End If

End Function

Private Sub Command1_Click()

Dim n As Integer, nfact As Long

n = Val(Text1.Text)

nfact = factorial(n)

Text2.Text = Str(nfact)

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Output:

[pic]

EXPERIMENT-15

TITLE- Write a program in V.B to show different color using different case statement.

METHODLOGY-

|Objects |Property |Default |Customized |
|Label |Caption |Label2 |Blank |
|Text Box |Text |Text2 |Blank |
|Command Button |Caption |Command1 |Display |
|Form1 |BackColor |Grey |Grey |
| |Caption |Form1 |Colors |

Graphical user interface(GUI):

[pic]

CODE-

Option Explicit

Dim scolor As String

Private Sub Command1_Click()

scolor = UCase(Text1.Text)

Select Case scolor

Case Is = "RED"

Label1.BackColor = vbRed

Case Is = "BLUE"

Label1.BackColor = vbBlue

Case Is = "GREEN"

Label1.BackColor = vbGreen

Case Is = "Yellow"

Label1.BackColor = vbYellow

Case Else

Label1.BackColor = vbWhite

Label1.Caption = "unknown"

Text1.Text = ""

End Select

End Sub

Output:

[pic]

-----------------------
Practical file of visual basic 6.0

Session-2012

You May Also Find These Documents Helpful

  • Visual Basic
  • Visual Basic
  • visual basic
  • Visual Basic
  • Visual Basic 6.0
  • Learning Visual Basic
  • Visual Basic Terms
  • IT visual basic textbook
  • Proposal for Visual Basic
  • Visual Basic Tutorial