Private Sub Command1_Click()
Dim x, y, n, i, sum As Integer
n = Val(Text1.Text)
x = 0
y = 1
Print x
Print y
For i = 3 To n
sum = x + y
Print sum
x = y
y = sum
Next i
End Sub
This tutorial is about some basic concepts in Computer Science and programming with Visual Basic and C++.
Wednesday, September 28, 2011
Program to calculate Factorial of a number in VB 6.0
Private Sub Command1_Click()
Dim n As Integer
Dim fact As Integer
fact = 1
n = Val(Text1.Text)
For i = 1 To n
fact = fact * i
Next
MsgBox "factorial of " & n & " is = " & fact
End Sub
Dim n As Integer
Dim fact As Integer
fact = 1
n = Val(Text1.Text)
For i = 1 To n
fact = fact * i
Next
MsgBox "factorial of " & n & " is = " & fact
End Sub
Subscribe to:
Posts (Atom)