0% found this document useful (0 votes)
63 views9 pages

Visual Basic Sample codes

The document contains several Visual Basic (VB) programs, including a simple calculator, temperature conversion from Celsius to Fahrenheit, a login page, factorial calculation, profit and loss assessment, and salary calculation with allowances. Each program includes the code and a brief description of its functionality. The programs demonstrate basic VB programming concepts and user interactions.

Uploaded by

bdebashreta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views9 pages

Visual Basic Sample codes

The document contains several Visual Basic (VB) programs, including a simple calculator, temperature conversion from Celsius to Fahrenheit, a login page, factorial calculation, profit and loss assessment, and salary calculation with allowances. Each program includes the code and a brief description of its functionality. The programs demonstrate basic VB programming concepts and user interactions.

Uploaded by

bdebashreta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1) Write a programe to implement a simple calculator using VB :-

Programme code:-
Private Sub Command1_Click()
Dim a, b, r As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r=a+b
Text3.Text = r
End Sub

Private Sub Command2_Click()


Dim a, b, r As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r=a-b
Text3.Text = r
End Sub

Private Sub Command3_Click()


Dim a, b, r As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r=a*b
Text3.Text = r
End Sub

Private Sub Command4_Click()


Dim a, b, r As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r=a/b
Text3.Text = r
End Sub

Private Sub Command5_Click()


End
End Sub

Program Output:-
2) Write a programe on Visual Basic to calculate a value of a farenhite
𝑪 𝑭−𝟑𝟐
Temperature to using a particular centigrate formula that is:- =
𝟓 𝟗

Programme code:-
Private Sub Command1_Click()
Dim C As Integer
Dim F As Integer
C = Text1.Text
F = (9 * C) / 5 + 32
Label2.Caption = C & "DEGREE CENTIGRADE=" & F & "DEGREE FAHRENHEIT"
End Sub

Program Output:-
3) Write a program to implement a single login page using VB. :-

Programme code:-
Private Sub cmdok_Click()
MsgBox "PASSWORD ACCEPTED"
End Sub

Program Output:-
4) Write a programe on Visual Basic to calculate Factrial of a number :-

Programme code:-
Private Sub Command1_Click()
N = CInt(Text1.Text)
FACT = 1
For I = 1 To N
FACT = FACT * I
Next I
Label2.Caption = "THE FACTORIAL OF " & N & "IS" & FACT & ","
End Sub

Private Sub Command2_Click()


End
End Sub

Program Output:-
5) Write a Program to calculator profit and loss of a shop owner. :-

Programme code:-
Private Sub Form_Load()
Dim cost As Double, sell As Double
cost = InputBox("ENTER COST PRICE OF ITEM :")
sell = InputBox("ENTER SELLING PRICE OF ITEM:")
Form1.Show
If sell >= cost Then
Print "no loss"
Else
Print "LOSS HAS BEEN MADE"
End If
End Sub

Program Output:-
6) Write a program in visul basic by which do the following tools:-
a) Input the basic pay of an employ.
b) Final DA(45% of basic)
HRA (15% of basic)
MA (5% of basic)
And show in text box
c) Calculator gross salary and show in text box(gross salary = BASIC + DA +
HRA + MA)

Programme code:-
Private Sub Command1_Click()
Dim BASIC_PAY As Integer
Dim DA, HRA, MA, SALARY As Integer
BASIC_PAY = Text1.Text
DA = BASIC_PAY * 0.45
Label2.Caption = "DA:" & DA
HRA = BASIC_PAY * 0.15
Label3.Caption = "HRA:" & HRA
MA = BASIC_PAY * 0.05
Label4.Caption = "MA:" & MA
SALARY = BASIC_PAY + DA + HRA + MA
Label5.Caption = "TOTAL SALARY:" & SALARY

End Sub

Private Sub Command2_Click()


Text1.Text = ""
Label2.Caption = ""
Label3.Caption = ""
Label4.Caption = ""
Label5.Caption = ""

End Sub

Private Sub Command3_Click()


End
End Sub

Program Output:-

You might also like