Vous êtes sur la page 1sur 10

Program to print Vowel

Private Sub Command1_Click()


Select Case (Text1.Text)
Case "a"
Label2.Caption = "Vowel"
Case "e"
Label2.Caption = "Vowel"
Case "I"
Label2.Caption = "Vowel"
Case "o"
Label2.Caption = "Vowel"
Case "u"
Label2.Caption = "Vowel"
Case Else
Label2.Caption = "Not Vowel"
End Select

End Sub

Private Sub Command2_Click()


End
End Sub

Area Calculation

Private Sub Command1_Click()


Dim a, h, b, r As Integer
Select Case (Val(Text1.Text))
Case 1
r = InputBox("Enter radious")
a = (22 / 7) * r * r
Label2.Caption = a
Case 2
b = InputBox("Enter Base")
h = InputBox("enter hight")
a = (1 / 2) * b * h
Label2.Caption = a
Case 3
b = InputBox("Enter breath")
h = InputBox("Enter height")
a=b*h
Label2.Caption = a
Case Else
Label2.Caption = "Wrong Input"
End Select

End Sub

Private Sub Command2_Click()


End
End Sub

Even Number Printing UPTO N

Private Sub Command1_Click()


Dim i As Integer
List1.Clear
For i = 1 To Val(Text1.Text)
If i Mod 2 = 0 Then
List1.AddItem i
End If
Next i
End Sub

Private Sub Command2_Click()


End
End Sub

Factorial of a Given Number

Private Sub Command1_Click()


Dim i, f As Integer
f=1
For i = 1 To Val(Text1.Text)
f=f*i
Next i
Label2.Caption = f
End Sub

Private Sub Command2_Click()


End
End Sub
Fibonacci Series

Private Sub Command1_Click()


Dim a, b, c, i As Integer
List1.Clear
a=0
b=1
List1.AddItem a
List1.AddItem b
For i = 1 To Val(Text1.Text) - 2
c=a+b
List1.AddItem c
a=b
b=c
Next i
End Sub

Private Sub Command2_Click()


End
End Sub

Reversing a Number

Private Sub Command1_Click()


Dim x, r, no As Variant
no = Val(Text1.Text)
Do While (no > 0)
x = no Mod 10
r = (Val(r) * 10) + Val(x)
no = Int(no / 10)
Loop
Label2.Caption = r
End Sub

Private Sub Command2_Click()


End
End Sub

Scroll Bar Demo

Private Sub HScroll1_Change()


Form26.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)

End Sub

Private Sub HScroll2_Change()


Form26.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

Private Sub HScroll3_Change()


Form26.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End Sub

Applying Font Formatting

Private Sub Command1_Click()


Label1.Font = Combo1.Text
Label1.FontSize = Val(Combo3.Text)
Select Case (Combo2.Text)
Case "Red"
Label1.ForeColor = vbRed
Case "Green"
Label1.ForeColor = vbGreen
Case "Blue"
Label1.ForeColor = vbBlue
End Select
End Sub

Private Sub Command2_Click()


End
End Sub

Private Sub Form_Load()


Combo1.AddItem "Times New Roman"
Combo1.AddItem "Arial"
Combo1.AddItem "Arial Black"
Combo2.AddItem "Red"
Combo2.AddItem "Green"
Combo2.AddItem "Blue"
Combo3.AddItem 10
Combo3.AddItem 20
Combo3.AddItem 30
End Sub
Sum of SDA

Private Sub Command1_Click()


Dim a(50), i, sum As Integer
For i = 1 To Val(Text1.Text)
a(i) = InputBox("Enter elements")
Next i
For i = 1 To Val(Text1.Text)
sum = sum + a(i)
Next i
Label2.Caption = sum
End Sub

Private Sub Command2_Click()


End
End Sub

Printing Even no. of SDA

Private Sub Command1_Click()


Dim a(50), i As Integer
For i = 1 To Val(Text1.Text)
a(i) = InputBox("Enter elements")
Next i
For i = 1 To Val(Text1.Text)
If Val(a(i)) Mod 2 = 0 Then
List1.AddItem a(i)
End If
Next i
End Sub

Private Sub Command2_Click()


End
End Sub

Count Vowels and Characters

Private Sub Command1_Click()


Dim a(50) As String
Dim i, v, c As Integer
For i = 1 To Val(Text1.Text)
a(i) = InputBox("Enter a character")
Next i
For i = 1 To Val(Text1.Text)
If a(i) = "a" Or a(i) = "A" Or a(i) = "I" Or a(i) = "i" Or a(i) = "o" Or a(i) = "O" Or _
a(i) = "U" Or a(i) = "u" Or a(i) = "e" Or a(i) = "E" Then
v=v+1
Else
c=c+1
End If
Next i
Label2.Caption = v
Label3.Caption = c
End Sub

Private Sub Command2_Click()


End
End Sub

Sorting an array

Private Sub Command1_Click()


Dim a(50), i, j, t As Integer
List1.Clear
For i = 1 To Val(Text1.Text)
a(i) = InputBox("Enter elements")
Next i
For i = 1 To Val(Text1.Text)
For j = 1 To Val(Text1.Text)
If Val(a(i)) < Val(a(j)) Then
t = Val(a(i))
a(i) = Val(a(j))
a(j) = Val(t)
End If
Next j
Next i
For i = 1 To Val(Text1.Text)
List1.AddItem a(i)
Next i
End Sub

Private Sub Command2_Click()


End
End Sub

Trace of a Matrix

Private Sub Command1_Click()


Dim a(50, 50), i, j, sum As Integer
For i = 1 To Val(Text1.Text)
For j = 1 To Val(Text2.Text)
a(i, j) = InputBox("Enter elements")
Next j
Next i

For i = 1 To Val(Text1.Text)
sum = sum + a(i, i)
Next i
Label2.Caption = sum
End Sub

Private Sub Command2_Click()


End
End Sub

Norm of a Matrix

Private Sub Command1_Click()


Dim a(50, 50), b(50, 50), i, j, sum, sq As Integer
For i = 1 To Val(Text1.Text)
For j = 1 To Val(Text2.Text)
a(i, j) = InputBox("Enter elements")
Next j
Next i

For i = 1 To Val(Text1.Text)
For j = 1 To Val(Text2.Text)
b(i, j) = Val(a(i, j)) * Val(a(i, j))
Next j
Next i

For i = 1 To Val(Text1.Text)
For j = 1 To Val(Text2.Text)
sum = sum + Val(b(i, j))
Next j
Next i

sq = Sqr(sum)
Label2.Caption = sq
End Sub

Private Sub Command2_Click()


End
End Sub
Transpose of a Matrix

Private Sub Command1_Click()


Dim a(50, 50), b(50, 50), i, j, m, n As Integer
Dim p As Variant

m = InputBox("Enter no of rows")
n = InputBox("Enter no of col")
For i = 1 To m
For j = 1 To n
a(i, j) = InputBox("Enter elements")
Next j
Next i

For i = 1 To m
For j = 1 To n
b(i, j) = Val(a(j, i))
Next j
Next i

For i = 1 To m
For j = 1 To n
p = p & " " & b(i, j)
Next j
List1.AddItem p
p = ""
Next i
End Sub

Blinking of a Text

Private Sub Command1_Click()


End
End Sub

Private Sub Timer1_Timer()


If Label1.Visible = True Then
Label1.Visible = False
Else
Label1.Visible = True
End If
End Sub
Traffic Signal Simulator

Private Sub Command1_Click()


End
End Sub

Private Sub Timer1_Timer()


If Shape1.Visible = True Then
Shape1.Visible = False
Shape2.Visible = True
Shape3.Visible = False
ElseIf Shape2.Visible = True Then
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = True
ElseIf Shape3.Visible = True Then
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
End If

End Sub

Digital Clock without Time$

Private Sub Command1_Click()


End
End Sub

Private Sub Form_Load()

End Sub

Private Sub Timer1_Timer()


Label3.Caption = Label3.Caption + 1
If Label3.Caption > 60 Then
Label2.Caption = Label2.Caption + 1
Label3.Caption = 0
End If
If Label2.Caption > 60 Then
Label1.Caption = Label1.Caption + 1
Label3.Caption = 0
Label2.Caption = 0
End If
If Label2.Caption > 60 Then
Label1.Caption = 0
Label3.Caption = 0
Label2.Caption = 0
End If
End Sub

Factorial of a Number

Private Sub Command1_Click()


Dim x As Variant
x = fact(Val(Text1.Text))
Label2.Caption = x
End Sub

Private Function fact(n As Integer) As Integer


Dim f As Integer
f=1
For i = 1 To n
f=f*i
Next i
fact = f
End Function

Private Sub Command2_Click()


End
End Sub

String Palindrome

Private Sub Command1_Click()


Dim l, i As Integer
Dim r As String
l = Len(Trim(Text1.Text))
For i = l To 1 Step -1
r = r & Mid$(Trim(Text1.Text), i, 1)
Next i
If r = Trim(Text1.Text) Then
Label2.Caption = "String is Palindrome"
Else
Label2.Caption = "String is not Palindrome"
End If
End Sub

Private Sub Command2_Click()


End
End Sub

Vous aimerez peut-être aussi