Skip to main content
Some Visual Basic Programs
----------------------------------------------------------------------------------

Program-1
Create a visual basic project to find +,-,*,/ two number


Coding
Private Sub Option1_Click()
Dim a, b, c As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a + b
Text3.Text = c
End Sub

Private Sub Option2_Click()
Dim a, b, c As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - b
Text3.Text = c
End Sub

Private Sub Option3_Click()
Dim a, b, c As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a * b
Text3.Text = c
End Sub

Private Sub Option4_Click()
Dim a, b, c As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a / b
Text3.Text = c
End Sub
Private Sub Command5_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Program-2
Create a visual basic project to find sum two number


Coding
Private Sub Option1_Click()
Dim a, b, c As Long
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a + b
Text3.Text = c
End Sub


Program-3
Create a visual basic project to find number is even/odd

Coding
Private Sub Command1_Click()
Dim N As Long
N = Val(Text1.Text)
If (N Mod 2 = 0) Then
Text2.Text = "EVEN"
Else
Text2.Text = "ODD"
End If
End Sub


Program-4
Create a visual basic project to find number is negative/positive

Coding
Private Sub Command1_Click()
Dim N As Long
N = Val(Text1.Text)
If (N < 0) Then
Text2.Text = "NEGATIVE"
Else
Text2.Text = "POSITIVE'"
End If
End Sub

Program-5
Create a visual basic project to change string lower case and uppercase

Coding
Private Sub Option1_Click()
S = Text1.Text
Text2.Text = UCase(S)
Text3.Text = LCase(S)
End Sub

Program-6
CREATE A VISUAL BASIC PROJEC TO CONVERSION TEMPERATURE



Coding
Private Sub Option1_Click()
Dim n, c As Long
n = Val(Text1.Text)
c = (n - 32) * 5 / 9
Text2.Text = c
End Sub
Private Sub Option2_Click()
Dim n, f As Long
n = Val(Text1.Text)
f = (9 * n / 5) + 32
Text2.Text = f
End Sub
Program-7
ENTER THREE NUMBERS AND FIND THE GREATEST ONE


Coding
Private Sub Command1_Click()
Dim A, B, C As Long
A = Val(Text1.Text)
B = Val(Text2.Text)
C = Val(Text3.Text)
If (A > B) And (A > C) Then
Text4.Text = " A"
Else
If (B > A) And (B > C) Then
Text4.Text = "B"
Else
Text4.Text = "C"
End If
End If
End Sub

Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
End Sub
Program-8
ENTER A NUMBER AND FIND THE CORRESPONDING MONTH NAME


Coding
Dim c, f As Long
Private Sub Command1_Click()
c = Val(Text1.Text)
Select Case c
Case 1: Text2.Text = "January"
Case 2: Text2.Text = "February"
Case 3: Text2.Text = "March"
Case 4: Text2.Text = "April"
Case 5: Text2.Text = "May"
Case 6: Text2.Text = "June"
Case 7: Text2.Text = "July"
Case 8: Text2.Text = "August"
Case 9: Text2.Text = "September"
Case 10: Text2.Text = "October"
Case 11: Text2.Text = "November"
Case 12: Text2.Text = "December"
Case Else
Text2.Text = "You have inserted a wrong value. Try again..."
End Select
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Program-9
CREATE A VISUAL BASIC PROJECT TO FIND FACTORIAL

Coding
Private Sub Command1_Click()
Dim A, F As Long
F = 1
A = Val(Text1.Text)
If (A < 1) Then
Text2.Text = "NOT VALID"
Else
While (A <> 1)
F = F * A
A = A - 1
Wend
Text2.Text = F
End If
End Sub

Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
Text1.SetFocus
End Sub

Program-10
ENTER A NUMBER AND FIND THE CORRESPONDING DAY NAME


Coding
Private Sub Command1_Click()
Dim c, f As Long
c = Val(Text1.Text)
Select Case c
Case 1: Text2.Text = "Sunday"
Case 2: Text2.Text = "Monday"
Case 3: Text2.Text = "Tuesday"
Case 4: Text2.Text = "Wednesday"
Case 5: Text2.Text = "Thursday"
Case 6: Text2.Text = "Friday"
Case 7: Text2.Text = "Saturday"
Case Else
Text2.Text = "wrong choice"
End Select
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub
Program-11
CREATE A VISUAL BASIC PROJECT TO CREATE LIST

Coding
Private Sub Command1_Click()
List1.AddItem Text1.Text
Text1.Text = " "
Text1.SetFocus
End Sub
Private Sub Command2_Click()
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Command3_Click()
List1.Clear
End Sub


Program-12
CREATE A VISUAL BASIC PROJECT TO CHANGE FORMS COLORS

Coding
Private Sub HScroll1_Change()
Form1.BackColor = RGB (HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub
Private Sub HScroll2_Change()
Form1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub
Private Sub HScroll3_Change()
Form1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub


Program-13
CREATE A VB PROJECT TO SHOW THE STAR PATTERN


Coding

Private Sub STAR_Click()
Dim i, j, n As Long
n = Val(Text1.Text)
Label1.Caption = Now
For i = 1 To n
For j = 1 To i
Print " * ";
Next j
Print Tab
Next i
End Sub
Private Sub CLEAR_Click()
Text1.Text = ""
Form1.Cls
End Sub

PROGRAM-14
CREATE A VB PROJECT TO SHOW THE TRAFFIC LIGHT

Coding
Dim d As Integer
Private Sub Form_Load()
d = 0
End Sub

Private Sub Timer1_Timer(index As Integer)
d = d + 1
Label1.Caption = d
Label3.Caption = Now
If (d = 1) Then
Shape1.FillColor = vbRed
Shape2.FillColor = vbWhite
Shape3.FillColor = vbWhite
Label2.Caption = "STOP"
End If
If (d = 2) Then
Shape1.FillColor = vbWhite
Shape2.FillColor = vbYellow
Shape3.FillColor = vbWhite
Label2.Caption = "READY"
End If
If (d = 3) Then
Shape1.FillColor = vbWhite
Shape2.FillColor = vbWhite
Shape3.FillColor = vbGreen
Label2.Caption = "GO"
d = 0
End If
End Sub

PROGRAM-15
DESIGN A VB PROJECT FOR CUT, COPY & PASTE OF A PROGRAM

Coding
Dim value As String
Private Sub CLEAR_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub COPY_Click()
Label1.caption = Now
value = Text1.Text
PASTE.Enabled = True
End Sub

Private Sub CUT_Click()
value = Text1.Text
Text1.Text = " "
PASTE.Enabled = True
End Sub

Private Sub PASTE_Click()
Text2.Text = " "
Text2.Text = value
End Sub

PROGRAM-16
DESIGN A VB PROJECT FOR FINDING THE AREA CODE

Coding
Private Sub CLS_Click()
Text1.Text = ""
Label3.Caption = ""
Text1.SetFocus
End Sub

Private Sub FIND_Click()
Text1.SetFocus
Dim PNO As String * 10
f = 0
PNO = Text1.Text
temp = Left(PNO, 4)
For i = 0 To code.ListCount
If code.List(i) = UCase(temp) Then
f = 1
Label3.Caption = city.List(i)
End If
Next
If f = 0 Then
MsgBox ("NO area with this code")
End If
End Sub

Private Sub Form_Load()
code.AddItem ("0522")
code.AddItem ("0562")
code.AddItem ("0145")
code.AddItem ("0571")
code.AddItem ("0532")
code.AddItem ("0536")
code.AddItem ("05252")
code.AddItem ("0549")
code.AddItem ("05242")

city.AddItem ("Lucknow")
city.AddItem ("Agra")
city.AddItem ("Ajmer")
city.AddItem ("Aligarh")
city.AddItem ("Allahabad")
city.AddItem ("Amethi")
city.AddItem ("Bahraich")
city.AddItem ("Ballia")
city.AddItem ("Barabanki")
End Sub

PROGRAM-17
CREATE A VB PROJECT TO FIND A LEAP YEAR

Coding

Private Sub CLS_Click()
Text1.Text = ""
Label3.Caption = ""
Text1.SetFocus
End Sub

Private Sub RESULT_Click()
x = leap(Val(Text1.Text))
If (x = 1) Then
Label3.Caption = "Leap Year"
Else
Label3.Caption = "Not leap Year"
End If
End Sub

Private Function leap(year As Integer)
If (year Mod 4 = 0 And year Mod 100 <> 0) Then
leap = 1
Else
leap = 0
End If
End Function

PROGRAM-18
DESIGN A VB PROJECT TO FIND THAT GIVEN STRING IS PALINDROME OR NOT

Coding

Private Sub CLS_Click()
Text1.Text = ""
Label3.Caption = ""
Text1.SetFocus
End Sub

Private Sub RESULT_Click()
Dim str1, str2 As String
str1 = Text1.Text
i = Len(str1)
str2 = StrReverse(str1)
If (str1 = str2) Then
Label3.Caption = "PALINDROME"
Else
Label3.Caption = "NOT PALINDROME"
End If
End Sub

Comments

Popular posts from this blog

O Level Practical Queestion Paper (MS-OFFICE, MSDOS, MS-EXCEL, ICT Resources)

MSDOS 1. Write command to display all files having extension ‘jpg’. 2. Write command to display all files of all types starting with letter ‘m’. 3. Write command to display all files having names up to ten characters with second last letter as ‘n’, e.g. intelligent. 4. Write a command to copy the file mars of type exe from the directory ‘space’ of drive U to another directory “universe” in drive S. 5. Write a command to delete the directory as well as the files of the directory ‘world’ on drive E. 6. Write command to display all file names on the disk in drive A and having an extension of no more than two characters.   7. Write command to copy all the files beginning with ‘m’ and whose file names has a ‘txt’ extension from drive A to the ‘\document’ directory on drive C. 8. Write set of commands to create a subdirectory of the root directory called ‘exercise’, and then move into it 9. Perform the following tasks using DOS commands in the DOS sh...

Learn Programming in UNIX

Q: - Write a program to input two numbers and add them?             gedit add.sh             clear             echo “enter two numbers:”             read a             read b             sum=`expr$a+$b`             echo $sum Syntax for if-else:- (1)          if test condition             then                 ---------                 --...

IICS College 15th August Celebration Day

IICS COLLEGE  15th August Celebration Day