


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















Software
System Software Ap plication Software
Application package Program / Language
Visual Basic is a compiler. It’s used to create / develop new applications software
The compiler is converting the Human Language to Computer Language with ASCII value. A 65 01000001
Human Language ASCII Computer Language
ASCII: American Standard Code for Information Interchange
Design the Form II. Set the Properties
Page 1 PREPARED BY MR.P.PERINPAKUMAR
Design time
III. Write the Coding IV. Save your Project
.vbp V. Test your Project
Tools Name Properties Short Name
Label Caption lbl
ab
Text box Text txt
Command button Caption cmd
√
Check box Caption chk
Option button (Radio button)
Caption opt
Frame Caption fra
I. Design the form
II. Set the properties Name = form Caption = First project Fore color = red Font Fount = Arial black Style = Bold PREPARED BY MR.P.PERINPAKUMARPage 2
Run time
Int = Integer : 7434 (Max 4 Digit) Long Int = Long Integer : 479492494 (Max 10 Digit) Double = Floating point number : 7432.47 (Max 2 Digit after decimal point) Float = Floating point number : 7432.47 (Max 6 Digit after decimal point) Char = Character : A (1 Character) String = String : A BCD
I. Arithmetic operators I.a. + Addition (a + b) I.b. - Subtraction (a - b) I.c. / Division (a / b) I.d. \ Integer Division (a \ b), (Here result is integer) I.e. * Multiplication (a * b) I.f. (^) Mod Modulo (a Mod b), (Reminder only for Integer value) I.g. ^ Exponentiation (N ^ m)=(N m^ )
II. Relational operator I.h. > Greater than I.i. < Less than I.j. >= Greater than or Equal to I.k. <= Less than or Equal to I.l. = Equal to I.m. != or <> Not equal to
III. Increment & Decrement operator I.n.
IV. Assign operator I.r. += Assign Add
PREPARED BY MR.P.PERINPAKUMARPage 4
I.s. -= Assign Subtract I.t. /= Assign Divide I.u. *= Assign Multiple
Sample 1- ( write a program answer of Add Two Numbers)
Label
Page 5 PREPARED BY MR.P.PERINPAKUMAR
lbl1txt2txt1cmd3cmd2cmd
End End Sub
Private Sub cmd3_Click() Txt1.Text = "" Txt2.Text = "" lbl4.Caption = "" End Sub
Sample (Write program sample calculator)
Coding
Private Sub cmd1_Click() lbl4.Caption = Val(Txt1.Text) + Val(Txt2.Text) End Sub
Private Sub cmd2_Click() lbl4.Caption = Val(Txt1.Text) - Val(Txt2.Text) End Sub
Private Sub cmd3_Click() lbl4.Caption = Val(Txt1.Text) / Val(Txt2.Text) End Sub
Private Sub cmd4_Click() lbl4.Caption = Val(Txt1.Text) * Val(Txt2.Text) End Sub
Page 7 PREPARED BY MR.P.PERINPAKUMAR
lbl1cmd6cmd7cmd5cmd4cmd3cmd2cmd1txt2txt
Private Sub cmd5_Click() lbl4.Caption = Val(Txt1.Text) Mod Val(Txt2.Text) End Sub
Private Sub cmd6_Click() Txt1.Text = "" Txt2.Text = "" lbl4.Caption = "" End Sub
Private Sub cmd7_Click() End End Sub
If Statement
The If statement is a logical function. There are have three type. These are I. If ………….. Else …………….. Statement II. If ………….. Else If …………... Statement III.Nexted IF
Syntax If (Conditions) Then (Statements) Else (Statements)
PREPARED BY MR.P.PERINPAKUMARPage 8
Txt2.Text = "" lbl4.Caption = "" End Sub
Private Sub cmd4_Click() End End Sub
Sample (Write a program sample salary sheet)
Condition Basic salary> Bonus=Basic salary x 10% Incentive= PREPARED BY MR.P.PERINPAKUMARPage 10
txt7txt6txt5lbl3lbl2txt4txt1txt2txt3lbl1cmd2cmd3cmd
Basic salary< Bonus=Basic salary x 5% Incentive=
Coding Private Sub cmd1_Click() If (txt3.Text > 10000) Then lbl1.Caption = Val(txt3.Text) * 10 / 100 lbl2.Caption = 750 Else lbl1.Caption = Val(txt3.Text) * 5 / 100 lbl2.Caption = 500 End If lbl3.Caption = Val(txt3.Text) + Val(txt4.Text) + Val(lbl1.Caption) + Val(lbl2.Caption) lbl4.Caption = Val(lbl3.Caption) - Val(txt5.Text) - Val(txt6.Text) End Sub
Private Sub cmd2_Click() txt1.Text = "" txt2.Text = "" txt3.Text = "" txt4.Text = "" lbl1.Caption = "" lbl2.Caption = "" lbl3.Caption = "" txt5.Text = "" txt6.Text = "" lbl4.Caption = "" End Sub
Private Sub cmd3_Click() End End Sub
Input Box
Page 11 PREPARED BY MR.P.PERINPAKUMAR
Coding Page 13 PREPARED BY MR.P.PERINPAKUMAR
txt1txt2txt3txt4lbl1lbl2lbl3txt5txt6lbl4cmd2cmd3cmd
Private Sub cmd1_Click() If (txt3.Text > 10000) Then lbl1.Caption = Val(txt3.Text) * 10 / 100 lbl2.Caption = 750 Else lbl1.Caption = Val(txt3.Text) * 5 / 100 lbl2.Caption = 500 End If lbl3.Caption = Val(txt3.Text) + Val(txt4.Text) + Val(lbl1.Caption) + Val(lbl2.Caption) lbl4.Caption = Val(lbl3.Caption) - Val(txt5.Text) - Val(txt6.Text) End Sub
Private Sub cmd2_Click() txt1.Text = "" txt2.Text = "" txt3.Text = "" txt4.Text = "" lbl1.Caption = "" lbl2.Caption = "" lbl3.Caption = "" txt5.Text = "" txt6.Text = "" lbl4.Caption = "" End Sub
Private Sub cmd3_Click() End End Sub
Private Sub Form_Load() a = InputBox("Your ID", "Enter your ID", "ID") If (a = "inpan") Then Form1.Visible = True Else b = MsgBox("Invalide ID", vbOKCancel, "Error") End If End Sub
PREPARED BY MR.P.PERINPAKUMARPage 14
Coding Private Sub cmd1_Click() If (txt2.Text >= 85) Then lbl1.Caption = "A" ElseIf (txt2.Text >= 65) Then lbl1.Caption = "B" ElseIf (txt2.Text >= 45) Then lbl1.Caption = "C" ElseIf (txt2.Text >= 25) Then lbl1.Caption = "S" Else lbl1.Caption = "W" End If End Sub
Private Sub cmd2_Click() txt1.Text = "" txt2.Text = "" lbl1.Caption = "" End Sub
Private Sub cmd3_Click() End End Sub
Example (Write the program to find the computer result)
PREPARED BY MR.P.PERINPAKUMARPage 16
lbl3lbl2lbl1txt3txt2txt1cmd3cmd2cmd
Condition
Visual Basic >= 60 C++ >= 60 Java# >=
Visual Basic < 60 C++ >= 60 Java# >=
Visual Basic >= 60 C++ < 60 Java# >=
Visual Basic >= 60 C++ >= 60 Java# <
Otherwise Fail
Coding Private Sub cmd1_Click() lbl1.Caption = Val(txt2.Text) + Val(txt3.Text) + Val(txt4.Text) lbl2.Caption = lbl1.Caption / 3 If (txt2.Text >= 60) And (txt3.Text >= 60) And (txt4.Text >= 60) And (lbl2.Caption >= 88) Then lbl3.Caption = "Good pass" ElseIf (txt2.Text >= 60) And (txt3.Text >= 60) And (txt4.Text >= 60) And (lbl2.Caption < 88) Then lbl3.Caption = "Standard pass" ElseIf (txt2.Text < 60) And (txt3.Text >= 60) And (txt4.Text >= 60) Then lbl3.Caption = "Re exam Visual Basic" ElseIf (txt2.Text >= 60) And (txt3.Text < 60) And (txt4.Text >= 60) Then lbl3.Caption = "Re exam C++" ElseIf (txt2.Text >= 60) And (txt3.Text >= 60) And (txt4.Text < 60) Then lbl3.Caption = "Re exam Java#" Else Page 17 PREPARED BY MR.P.PERINPAKUMAR
Average >= 88 Good pass Average <= 88 Standard pass
Re exam Visual BasicRe exam C++Re exam Java#
Condition Year mod 4 = Year mod 100! 0
Or Year mod 4= Year mod 100= Year mod 400=
Coding Private Sub cmd1_Click() If (txt1.Text Mod 4 = 0) Then If (txt1.Text Mod 100 = 0) Then If (txt1.Text Mod 400 = 0) Then lbl1.Caption = "This year is leap year" Else lbl1.Caption = "This year is not leap year" End If Else lbl1.Caption = "This year is leap year" End If Else lbl1.Caption = "This year is not leap year" End If End Sub
Private Sub cmd2_Click() txt1.Text = "" lbl1.Caption = "" End Sub
Private Sub cmd3_Click() Page 19 PREPARED BY MR.P.PERINPAKUMAR
Leap year otherwise Not Leap year
End End Sub
Example (Write a program of ABC CO Salary sheet)
Condition
Experience >10 years Basic salary > Rs.
Experience >10 years Basic salary < Rs.
PREPARED BY MR.P.PERINPAKUMARPage 20
Bonus = Basic salary x 25% Incentive = Basic salary x 5%
Bonus = Basic salary x 10% Incentive = Basic salary x 3%
Bonus = Basic salary x 15% Incentive = Basic salary x 4%