Visual Basic Practical File

Only available on StudyMode
  • Download(s) : 348
  • Published : April 1, 2013
Open Document
Text Preview
Practical 1

Aim: - WAP to perform arithmetic operation using command buttons. (Declare variables globally).

Design:-

Source code :-

Path :- F:\Program Files\Microsoft Visual Studio\COMMON\IDE\IDE

‘Initialize variable global
Dim a, b, c As Integer
‘event for clear content
Private Sub Command1_Click()
‘clear text box
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""

End Sub

‘option for addition
Private Sub Option1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
‘Perform operation
c = a + b
Text3.Text = c
Label4.Caption = "Addition of two given number ="
End Sub
‘option for sub
Private Sub Option2_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - b
Text3.Text = c
Label4.Caption = "Subtraction of two given number ="
End Sub
‘option for multiplication
Private Sub Option3_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a * b
Text3.Text = c
Label4.Caption = "Multiplication of two given number ="
End Sub
‘option for division
Private Sub Option4_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a / b
Text3.Text = c
Label4.Caption = "Division of two given number ="
End Sub
‘option for modulas
Private Sub Option5_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a Mod b
Text3.Text = c
Label4.Caption = "Modulus of two given number ="
End Sub

Practical 2

Aim :- WAP to take input of principal, rate & time and calculate simple interest & compound interest.

Design:-

Source code:-

Path:- E:\Documents and Settings\ss\Myfiles

‘variable declaration globally
Dim SI, CI, P, R, T, AMT, I, EXP As Double
‘command for clear textbox
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Visible = False
Label5.Visible = False
End Sub
‘command for exit from program

Private Sub Command2_Click()
End
End Sub

‘set height and width of form
Private Sub Form_Load()
Label5.Visible = False
Text4.Visible = False
Form1.Width = 15000
Form1.Height = 8500
End Sub
‘calculate simple interest
Private Sub Option1_Click()
Label5.Visible = True
Text4.Visible = True
Label5.Caption = "SIMPLE INTEREST"
P = Text1.Text
R = Text2.Text
T = Text3.Text
‘ formula for simple interest
SI = (P * R * T) / 100

Text4.Text = SI

End Sub
‘Calculate compound interest
Private Sub Option2_Click()
Text4.Visible = True
Label5.Visible = True
Label5.Caption = "COMPOUND INTEREST"
P = Text1.Text
R = Text2.Text
T = Text3.Text
‘ start loop
For I = 1 To T

EXP = (1 + R) * (1 + R)
Next ‘ end loop
AMT = P + EXP
Text4.Text = AMT
End Sub

Practical 3

Aim :- WAP for temperature conversion using option button.

Design :-

Source Code:-

Path:- H:\bc a vb practical list\7505\VB\option_button

'This program converts °F to °C and vice versa

Private Sub cmdConvert_Click()

Dim intFivebynine As Integer
intFivebynine = 5 / 9

If ((optFtoC = False) And (optCtoF = False)) Then
intSelect = MsgBox("Please Select A Conversion Method", vbExclamation, "ERROR!") End If

If ((txtCelcus = "") And (txtFerin = "")) Then
intEnter = MsgBox("Please Enter A Number.", vbExclamation, "ERROR") End If

If optFtoC = True Then
txtCelcus = 5 / 9 * ((txtFerin) - 32) 'converts the temperature rounded = Int((txtCelcus + 0.0005) * 100) / 100 'rounds the number txtCelcus = rounded
End If

If optCtoF = True Then
txtFerin = (txtCelcus * 9) / 5 + 32 'converts the temperature rounded = Int((txtFerin + 0.0005) * 100) / 100 'rounds the number txtFerin = rounded
End If
End Sub

Private Sub Label3_Click()
End 'closes program
End Sub

Private Sub mnuAbout_Click()
frmAbout.Show 'shows about screen
frmTempConversion.Visible = False 'makes main form not visible

End Sub

Practical 4

Aim:- WAP to launch a rocket using pictures box and timer control

Design :-

Source code :-

Path:- F:\rocket lounch\MyDocument\

Dim top1 As Integer
‘Enable timer‘s value...
tracking img