Computer Science And Application Practicals
Tuesday, 18 May 2021
Wednesday, 13 February 2019
SYBBA (CA) VB 6.0
Title: Write a VB program to find the
prime numbers between 1 to100 and display it onto the form.
Dim
prime, n As Double
Private
Sub Command1_Click()
prime
= 1
n
= Val(Text1.Text) //100
For
i = 2 To n - 1
If
(n Mod i = 0) Then
prime
= 0
End
If
Next
If
(prime = 0) Then
MsgBox
" The no is not prime"
Else
MsgBox
" The no is prime"
End
If
End
Sub
Title: create a following application in
vB .
the form should contain the following
menu
Draw Modify Exit
Circle shrink
Expand
Erase
on
selection of menu option 'Circle' a circle should be drawn on screen the user can shrink ,expand or erase
the circle by selection the menu option
or by display a popup menu after the right mouse button is clicked or pressed . the popup menu should
contain the option Shrink, Expand or Erase which should perform the same operation as the menu
option
--------------------------------------------------------------------------
Private
Sub circle_Click()
Me.Circle
(1500, 1500), 1500
End
Sub
Private
Sub erase_Click()
Me.Cls
End
Sub
Private
Sub exit_Click()
End
End
Sub
Private
Sub expand_Click()
Me.Cls
Me.Circle
(2500, 2500), 2500
End
Sub
Private
Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If
Button = vbRightButton Then
End
Sub
Private
Sub shrink_Click()
Me.Cls
Me.Circle
(600, 600), 600
End
Sub
Title Program Name:Write a vb program to
find sum of first and last
digit
Private
Sub Command1_Click()
Dim
i, j, s As Integer
i
= InputBox("enter no")
j1
= i Mod 10
Do
While i <> 0
j
= i Mod 10
i
= i \ 10
Loop
s
= j + j1
MsgBox
s
End Sub
-
Title :Write a VB program for string concatenation
Private
Sub Command1_Click()
Dim
a, b, c As String
a
= Text1.Text
b
= Text2.Text
c
= Text3.Text
c
= a & b
Text3.Text
= c
End
Sub
Write
a VB program to create a Stop Watch. It contains buttons Start, Stop, Pause,
and Reset. It should display time in hours, minute, second, millisecond
Dim
hr As Integer
Dim
mn As Integer
Dim
sec As Integer
Dim
ms As Integer
Private
Sub Command1_Click()
Timer1.Enabled
= True
End
Sub
Private
Sub Command2_Click()
Timer1.Enabled
= False
hr
= 0
mn
= 0
sec
= 0
ms
= 0
Label1.Caption
= hr & " : " & mn & " : " & sec &
" : " & ms
End
Sub
Private
Sub Command3_Click()
Timer1.Enabled
= False
End
Sub
Private
Sub Command4_Click()
hr
= 0
mn
= 0
sec
= 0
ms
= 0
Title Write a VB program to display the
reverse of a given number using function.
Private
Sub Command1_Click()
rev
End
Sub
Function
rev()
Dim
n, r, s As Integer
n
= InputBox("Enter No")
While
n <> 0
r
= n Mod 10
s
= s * 10 + r
n
= n \ 10
Wend
MsgBox
s
End
Function
Title Write a VB Program to find
Multiplication of two matrices.
Dim
m1(3, 3) As Integer
Dim
m2(3, 3) As Integer
Private
Sub Form_Load()
MsgBox
"Enter First Matrix"
For
i = 0 To 2
For j = 0 To 2
Str1 = InputBox("Enter Element
" & i & " : " & j, "Input")
m1(i, j) = Val(Str1)
Next
Next
MsgBox
"Enter Second Matrix"
For
i = 0 To 2
For j = 0 To 2
Str1 = InputBox("Enter Element
" & i & " : " & j, "Input")
m2(i, j) = Val(Str1)
Next
Next
End
Sub
Title Design an application that
contains one label button, two combo boxes, one box contains any text and
second box contain color names. Write a VB program to set caption and
background color to the label control from respective combo boxes.
Private
Sub Combo1_Click()
Label1.Caption
= Combo1.Text
End
Sub
Private
Sub Combo2_Click()
Dim
str As String
str
= Combo2.Text
Select
Case str
Case
"BLUE"
Label1.BackColor
= vbBlue
Case
"RED"
Label1.BackColor
= vbRed
Case
"GREEN"
Label1.BackColor
= vbGreen
Case
"YELLOW"
Label1.BackColor
= vbYellow
End
Select
End
Sub
Title
Write a VB program to find the roots of quadratic equation
Option
Explicit
Private
Sub Command1_Click()
Dim
a, b, c, ds, r1, r2 As Double
a
= InputBox("enter value")
b
= InputBox("enter value")
c
= InputBox("enter value")
ds
= (b * b) - (4 * a * c)
If
(ds < 0) Then
MsgBox
"roots are imaginary"
Else
r1
= (-b + Sqr(ds)) / (2# * a)
r2
= (-b - Sqr(ds)) / (2# * a)
MsgBox
r1 & " " & vbNewLine & r2
End
If
End
Sub
Title. Write a VB program to display all
even and odd numbers from an array.
Option
Explicit
Private
Sub Command1_Click()
Dim
i, j, a(5) As Integer
For
i = 0 To 4
a(i) = InputBox("Enter any no")
If a(i) Mod 2 = 0 Then
Text1.Text = Text1.Text & "Even No
is" & a(i) & vbNewLine
Else
Text1.Text = Text1.Text & "Odd No
is" & a(i) & vbNewLine
End If
Next
End
Sub
Title.
Write a VB program to check whether given number is perfect or not by using
‘msgbox’.
Private
Sub Command1_Click()
Dim
i, n As Integer
n
= Val(InputBox("Enter No.", n))
Sum
= 0
For
i = 1 To n / 2
If
(n Mod i = 0) Then
Sum
= Sum + i
End
If
Next
i
If
(Sum = n) Then
MsgBox
" The perfect no is := " & n, vbOKOnly
Else
MsgBox
" The no is not perfect := " & n, vbOKOnly
End
If
End
Sub
Title Write a VB program to find
factorial of given no.
----------------------------------------------------------------
Private
Sub Command1_Click()
Dim
i, p As Double
factorial
= Val(InputBox("Enter no", factorial))
p
= 1
For
i = 1 To factorial
p
= p * i
Next
i
MsgBox
"factoroal := " & p, vbOKOnly
End
Sub
Title Write a VB program to find
factorial of given no.
----------------------------------------------------------------
Private
Sub Command1_Click()
Dim
i, p As Double
factorial
= Val(InputBox("Enter no", factorial))
p
= 1
For
i = 1 To factorial
p
= p * i
Next
i
MsgBox
"factoroal := " & p, vbOKOnly
End
Sub
Title Write a VB
program to convert a temperature from Celsius to Fahrenheit and vice versa
Private Sub Command1_Click()
Text2 = Val(Text1.Text) * 33.8
End Sub
Private Sub Command2_Click()
Text1 = Val(Text2.Text) * 33.8
End Sub
Dim n, str, s, r As Integer
Private Sub Command1_Click()
s = 0
n = InputBox("enter number")
While n <> 0
r = n Mod 10
s = str
n = n \ 10
Wend
If n Mod 2 = 0 Then
s = str + r
End If
MsgBox s
End Sub
Title
Write VB program to design following form
Private Sub Check1_Click()
If Check1.Value = 1 Then
Text1.FontBold = True
Text2.FontBold = True
End If
If Check1.Value = 0 Then
Text1.FontBold = False
Text2.FontBold = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Text1.FontItalic = True
Text2.FontItalic = True
End If
If Check2.Value = 0 Then
Text1.FontItalic = False
Text2.FontItalic = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
Text1.FontUnderline = True
Text2.FontUnderline = True
End If
If Check3.Value = 0 Then
Text1.FontUnderline = False
Text2.FontUnderline = False
End If
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Check1.Value = Unchecked
Check2.Value = Unchecked
Check3.Value = Unchecked
Option1.Value = False
Option2.Value = False
Option3.Value = False
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
End Sub
Private Sub Option1_Click()
Text1.ForeColor = vbRed
Text2.ForeColor = vbRed
End Sub
Private Sub Option2_Click()
Text1.ForeColor = vbGreen
Text2.ForeColor = vbGreen
End Sub
Private Sub Option3_Click()
Text1.ForeColor = vbBlue
Text2.ForeColor = vbBlue
End Sub
Private Sub Option4_Click()
Text1.ForeColor = vbBlack
Text2.ForeColor = vbBlack
End Sub
Title
Write a VB program to check whether the given Armstrong number is present in
array or not.
Private Sub Command1_Click()
Dim no As Integer
Me.Show
For no = 1 To 1000
no1 = no
Sum = 0
While no > 0
remnd = Int(no Mod 10)
Sum = Sum + (remnd * remnd * remnd)
no = Int(no / 10)
Wend
no = no1
If Sum = no Then
Print vbCrLf & no
End If
Next
End Sub
Title
Create an application in VB to display 4 X 4 squares
on the screen. One of the block will be active with black color all other block
will be fill with blue color. Provide a command button as follows to move the
active cell the active cell should be change only if it is within the boundary.
![]() |
![]() |
![]() |
![]() |
Dim cnt As Integer
Private Sub down_Click()
cnt = cnt + 4
If cnt > 15 Then
cnt = cnt - 4
End If
Form_Load
End Sub
Private Sub Form_Load()
For i = 0 To 15
Label1(i).BackColor = vbBlue
Next i
Label1(cnt).BackColor = vbBlack
End Sub
Private Sub next_Click()
If cnt <> 3 And ant <> 7 And
cnt <> 11 And cnt <> 15 Then
cnt = cnt + 1
End If
Form_Load
End Sub
Private Sub previous_Click()
If cnt <> 0 And cnt <> 4 And
cnt <> 8 And cnt <> 12 Then
cnt = cnt - 1
End If
Form_Load
End Sub
Private Sub up_Click()
cnt = cnt - 4
If cnt < 0 Then
cnt = cnt + 4
End If
Form_Load
End Sub
Title
: Write a VB program Progessbar with timer .
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Timer1.Interval = 500
Timer1.Enabled = True
ProgressBar1.Value = ProgressBar1.Value
+ 20
If ProgressBar1.Value = 100 Then
Form2.Show
If ProgressBar1.Value = 100 Then
MsgBox "Pandurang Gangurde"
End If
End If
End Sub
Subscribe to:
Posts (Atom)