Hello everybody...
I did a project in c++ about factorials.
Now i will do it on VB6.
But my problem is somehow my output is always 1.
So i think my funktion i made take no action at all.
Would be greate if someone can spott my error...Thank you
Private Sub cmdCalculate_Click()
Dim n1 As Long
Dim n2 As Long
Dim n3 As Long
n3 = Factorial(n1) / Factorial(n1 - n2)
lblDisplay.Caption = n3
End Sub
Public Function Factorial(ByVal Factor As Byte) As Variant
If Factor = 0 Then
Factorial = 1
Else
Factorial = Factor * Factorial(Factor - 1)
End If
End Function
Private Sub TxtNumb1_KeyPress(KeyAscii As Integer)
If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = 8 Then
'Allows only numbers and backspace key
Else
KeyAscii = 0
End If
txtNumb1.Text = n1
End Sub
Private Sub TxtNumb2_KeyPress(KeyAscii As Integer)
If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = 8 Then
'Allows only numbers and backspace key
Else
KeyAscii = 0
End If
txtNumb2.Text = n2
End Sub
Private Sub cmdClear_Click()
txtNumb1 = " "
txtNumb2 = " "
lblDisplay = " "
End Sub
Private Sub cmdExit_Click()
End
End Sub