Question 1 WAP To Calculate The Factorial of Any Number (A) Using Function (B) Using Sub Procedure
Question 1 WAP To Calculate The Factorial of Any Number (A) Using Function (B) Using Sub Procedure
3(a)
Public Function Greatest(ByVal a As Integer, ByVal b As Integer, ByVal c As Integer)
If a > b And a > c Then
Greatest=a
ElseIf b > c And b > a Then
Greatest=b
ElseIf c > a And c > b Then
Greatest=c
End If
End Function
3 (b)
Dim a, b, c As Integer
Private Sub Command1_Click()
a = InputBox("ENTER THE FIRST NUMBER")
b = InputBox("ENTER THE SECOND NUMBER")
c = InputBox("ENTER THE THIRD NUMBER")
If a > b And a > c Then
MsgBox "The Greatest Number is A."
ElseIf b > c And b > a Then
MsgBox "The Greatest Number is B."
ElseIf c > a And c > b Then
MsgBox "The Greatest Number is C."
End If
End Sub
(b)
Private Sub Command1_Click()
Dim I As Variant
I = Text1.Text
Text1.Text = Text2.Text
Text2.Text = I
End Sub
5 (b)
Or
Dim A(20) as Integer
Private Sub Command3_Click()
A(0)=0
A(1)=1
For I =2 to 19
A(I)=a(I -1)+a(I -2)
Next I
For I =0 to 19
Print A(I)& Space(3);
Next I
End Sub
For i = 1 To 3
For J = 1 To 3
B(i, J) = InputBox("B Array Element no Row=" & i & "Col=" & J)
Next J
Next i
For i = 1 To 3
For J = 1 To 3
For k = 1 To 3
Prod(i, J) = Prod(i, J) + A(i, k) * B(k, J)
Next k
Next J
Next i
List2.AddItem "Srinagar"
List2.AddItem "Chandigarh"
List2.AddItem "Delhi"
List2.AddItem "Lucknow"
List2.AddItem "Mumbai"
End Sub
Private Sub
CmdMinus_Click(Index As
Integer)
a = Val(TxtOne.Text)
b = Val(TxtTwo.Text)
c=a-b
TxtResult.Text = Val(c)
End Sub
Using Module :
Public Function power(n As Integer, e As Integer) As Long
Dim res As Long
power = n ^ e
End Function