Sunteți pe pagina 1din 21

PROGRAM 1

To create a form and interact with the mouse and keyboard using VB.
PROGRAM 2

To create an application with the data types, variants, and array using VB.
PROGRAM 3

Write a visual basic program to perform basic mathematical operations.

Module Module1

Sub Main()

Dim a As Integer

Dim b As Integer

a = 10

b=5

'Sum of a And be

Console.WriteLine("Sum of two numbers: " & (a + b))

'Submission of two number

Console.WriteLine("Submission of two numbers: " & (a - b))

'Division of two number

Console.WriteLine("Div of two numbers: " & (a / b))


'Multiplication of two number

Console.WriteLine("Mul of two numbers: " & (a * b))

Console.ReadLine()

End Sub

End Module

PROGRAM 4

Vb program to create calculator application to perform addition, subtraction, multiplication and division
cure function for the calculation.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Button1.Click

Dim num1, num2, difference, product, quotient As Single

num1 = TextBox1.Text

num2 = TextBox2.Text

sum=num1+num2

difference=num1-num2

product = num1 * num2

quotient=num1/num2

Label1.Text=sum

Label2.Text=difference

Label3.Text = product

Label4.Text = quotient

End Sub

PROGRAM 5

To Create an application for file system controls using VB


PROGRAM 6

To Create an database using data control and implement it in an application using VB.
https://bedeveloper.wordpress.com/vb-
simple-program/1-write-a-vb-program-to-
find-the-prime-numbers-between-1-to100-
and-display-it-onto-the-form/
PROGRAM 7
Write a VB program to find the prime
numbers between 1 to100 and display it onto
the form.
 

Private Sub cmdPrime_Click()


Dim p, n, i As Integer
p=1
Print “Prime Numbers are : ”
For n = 1 To 100
For i = 2 To n – 1
If n Mod i = 0 Then
p=0
Exit For
Else
p=1
End If

Next
If p = 1 Then
Print n
End If

Next
End Sub

PROGRAM 8

Write VB program to place three text boxes


onto the form. Enter different strings in first
and second textbox. On clicking to command
button, concatenation of two strings should
be displayed in third text box.
 
9
 
Private Sub cmdClear_Click()
txtStr1.Text = “”
txtStr2.Text = “”
txtStr3.Text = “”
txtStr1.SetFocus
End Sub

Private Sub cmdDisplay_Click()


txtStr3.Text = txtStr1.Text + txtStr2.Text
End Sub

Private Sub cmdExit_Click()


Unload Me
End Sub

Private Sub Form_Activate()


txtStr1.SetFocus
End Sub

PROGRAM 9

Write a VB program to take one list box, it


contains name of picture file. If you click on
particular picture file name then
corresponding picture should be display onto
the picture box.
 

Private Sub Form_Load()


List1.Clear
List1.AddItem “Sunset”
List1.AddItem “Water Lilies”
List1.AddItem “Winter”
List1.AddItem “Blue hills”
End Sub
Private Sub List1_Click()
For i = 0 To List1.ListCount – 1
If List1.ListIndex = 0 Then
Label2.Caption = “Sunset”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My
Pictures\Sample Pictures\Sunset.jpg”)
ElseIf List1.ListIndex = 1 Then
Label2.Caption = “Water Lilies”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My
Pictures\Sample Pictures\Water lilies.jpg”)
ElseIf List1.ListIndex = 2 Then
Label2.Caption = “Winter”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My
Pictures\Sample Pictures\Winter.jpg”)
Else
Label2.Caption = “Blue hills”
Picture1.Picture = LoadPicture(“C:\Documents and Settings\All Users\Documents\My
Pictures\Sample Pictures\Blue hills.jpg”)
End If
Next
End Sub

PROGRAM 10

Write a VB program to display age in year,


month, days, hours, minutes, seconds.
 
13
 
4
 
Rate This

Private Sub cmdClear_Click()


Text1.Text = “”
Text2.Text = “”
Text1.SetFocus
End Sub

Private Sub cmdDisplay_Click()


Dim b As Date
Dim d As Date
Dim age As Date
b = Text1.Text
d = Format$(Now, “dd/mm/yyyy hh:mm:ss “)
age = Format$(d – b, “dd/mm/yyyy hh:mm:ss”)

Text2.Text = Year(age)
Text3.Text = Month(age)
Text4.Text = Day(age)
Text5.Text = Hour(age)
Text6.Text = Minute(age)
Text7.Text = Second(age)
End Sub

Private Sub cmdExit_Click()


Unload Me
End Sub

Write a VB Program to design a simple calculator to perform addition, subtraction, multiplication and
division(Use functions for the calculations).

Design a User Interface (UI) to accept the student details such as name, department and total marks.
Validate the input data and calculate the percentage and division.

Design a VB application which has MDI and Child forms. Create a menu having the items such as file
(New, Open),Format (Font, Regular, Bold ,Italic) and Exit in the MDI form. Also create a text box and use
a Common Dialog Box control for changing the font, fore color and back color of the text box.

VB program to Encrypt and Decrypt a string. (Use Rnd() to generate the Encryption and Decryption
keys).

Create a Vending machine application ,that display images for four snacks and corresponding labels that
indicates the number for each snack. The GUI should contain a text box in which the user specifies the
number of desired snack. When the dispense snack button is clicked, it should display on a label the
name of the snack dispensed. At end it should print (display)the bill of the product.

Design a small Alarm Clock Application.

Write a VB Program to Validate the username and password form the database and display the
appropriate message.(Use Data Control)
Write an application for Airline Reservation System, which allows the user to book ticket on a particular
date for a particular type of class. At the end, once the ticket is booked, if should display a boarding pass
indication the person’s seat no., type of class and total fare. Input validations should be done properly.
You can use arrays or databases for storing the information.

Design a VB application to accept the Item Details (Item ID, Item Name, MFD Date, Unit Of Measure and
RatePerUnit).Item Id should be a system generated ID. The application should allow operations –Add,
Modify, Delete ,Update and Navigations of the items. Use ADO Date controls and Grid controls.

Design a VB application to record the employee details such as EmpId, EmpName, Designation and
BaiscPay . Calculate the DA, HRA, Deduction and Gross Salary.(Make the necessary assumptions )Use
Select .. case for decision making.

Design a mini ATM application which validates the user on the basis of its account no., and password.
After the validation customer is allowed to do many operations such as withdrawal, mini statement,
checking balance etc, Application should perform the concerned operation and the account of the user
should be updated accordingly.

VB program to calculate the simple interest and compound interest. Use DLLs for the calculation.

1) Develop an application to prepare student result  based on the marks entered.

https://www.computercoursestudy.com/2016/09/student-mark-list-program-in-visual.html

PROGRAM 1 1

Write a VB program to accept the details of


student and display mark sheet details on
grid control.( rollno, student name, class,
sub1, sub2, sub3, total, percentage, grade)
 
 
Rate This

Private Sub Command1_Click()


Static i As Integer
For j = 1 To MSFlexGrid1.Cols – 4
MSFlexGrid1.Row = i + 1
MSFlexGrid1.Col = j
MSFlexGrid1.Text = Text1.Item(j)
Text1.Item(j) = “”
Next
i=i+1
End Sub

Private Sub Command2_Click()


Unload Me
End Sub

Private Sub Command3_Click()


Dim i As Integer
Dim sum As Integer
Static j As Integer
sum = 0
MSFlexGrid1.Row = j + 1
For i = 4 To MSFlexGrid1.Col
MSFlexGrid1.Col = i
sum = sum + Val(MSFlexGrid1.Text)
Next
MSFlexGrid1.Col = MSFlexGrid1.Cols – 3
MSFlexGrid1.Text = sum
MSFlexGrid1.Col = MSFlexGrid1.Cols – 2
per = sum / 3
MSFlexGrid1.Text = per
MSFlexGrid1.Col = MSFlexGrid1.Cols – 1
If per >= 70 Then
MSFlexGrid1.Text = “Distinction”
ElseIf per < 70 And per >= 60 Then
MSFlexGrid1.Text = “First”
ElseIf per < 60 And per >= 50 Then
MSFlexGrid1.Text = “Second”
ElseIf per < 50 And per >= 40 Then
MSFlexGrid1.Text = “Pass”
Else
MSFlexGrid1.Text = “Fail”
End If
j=j+1
Text1(1).SetFocus
End Sub

Private Sub Form_Activate()


Text1(1).SetFocus
End Sub

Private Sub Form_Load()


Dim Items(6) As String
Dim i As Integer
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = 0
MSFlexGrid1.Text = “Sr.No”
For i = 1 To MSFlexGrid1.Rows – 1
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = i
MSFlexGrid1.Text = i
Next

MSFlexGrid1.Row = 0
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = “RollNo”
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = “Stud Name”
MSFlexGrid1.Col = 3
MSFlexGrid1.Text = “Class”
MSFlexGrid1.Col = 4
MSFlexGrid1.Text = “Sub1”
MSFlexGrid1.Col = 5
MSFlexGrid1.Text = “Sub2”
MSFlexGrid1.Col = 6
MSFlexGrid1.Text = “Sub3”
MSFlexGrid1.Col = 7
MSFlexGrid1.Text = “Total”
MSFlexGrid1.Col = 8
MSFlexGrid1.Text = “Percentage”
MSFlexGrid1.Col = 9
MSFlexGrid1.Text = “Grade”
End Sub

PROGRAM 12
Write a VB application to calculate simple interest.

Dim principal As Double

Dim rate As Double

Dim period As Double

Dim simple_interest As Double

Dim total_amount As Double

Private Sub btnClear_Click ()

txtPrincipal. Text = " "

txtPeriod. Text = " "

txtRate. Text = " "

txtTot. Text = " "

txtSI. Text = " "

End Sub

Private Sub btnExit_Click ()

SIcalculator.Hide

End Sub

Private Sub btnSI_Click()

simple_interest = principal * rate * period

txtSI. Text = Str (simple_interest)

End Sub

Private Sub btnTot_Click()

total_amount = simple_interest + principal

txtTot. Text = Str(total_amount)

End Sub

Private Sub txtPeriod_Change ()

txtRate. Text = Str(rate)

period = Val(txtPeriod. Text)

End Sub
Private Sub txtPrincipal_Change()

principal = Val(txtPrincipal.Text)

End Sub

Private Sub txtRate_Change()

rate = Val(txtRate. Text)

rate = rate / 100

End Sub

https://notesformsc.org/programming/visual-basic-6-tutorial/how-to-write-a-visual-basic-program/

http://bca-rises.blogspot.com/2012/08/write-program-in-visual-basic-to.html

2) Design an application that performs arithmetic operations. (+,-,*,/)     

3) Develop an application that accepts principal amount, rate of interest and time from the user.
Then it computes the simple interest and displays
it.                                                                                         

4) Obtain age of a person and determine through a  function whether it falls within range of 18-
40 years

5) Design a VB application that displays following menu

Student  -> new student

View -> report card , toppers details

Exit

6) Develop a database application


                                                                         

7) Create a VB application that lets the user decide the height and width of the shape through
scroll bars.
PROGRAM 13

Design an application that accepts an item name from the user and adds it to a list box.

ake the following steps −

 Drag and drop two labels, a button and a ListBox control on the form.

 Set the Text property of the first label to provide the caption "Choose your favourite
destination for higher studies".

 Set the Text property of the second label to provide the caption "Destination". The text on
this label will change at runtime when the user selects an item on the list.

 Click the listbox and the button controls to add the following codes in the code editor.

Public Class Form1


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
' Set the caption bar text of the form.
Me.Text = "tutorialspont.com"
ListBox1.Items.Add("Canada")
ListBox1.Items.Add("USA")
ListBox1.Items.Add("UK")
ListBox1.Items.Add("Japan")
ListBox1.Items.Add("Russia")
ListBox1.Items.Add("China")
ListBox1.Items.Add("India")
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
MsgBox("You have selected " + ListBox1.SelectedItem.ToString())
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs)


Handles ListBox1.SelectedIndexChanged
Label2.Text = ListBox1.SelectedItem.ToString()
End Sub
End Class

9) Create an application that offers various food items to select from and a mode of payment. It
then displays the total amount payable.

S-ar putea să vă placă și