437,594 Members | 2,016 Online Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

# Calculate the factorial

 P: 1 Dear Sir/Madam, I have one assignment , which need me to write a program to calculate the factorial of an integer, then press the button that would display the result in a label.3 & the program should warn the user if the iinput is not a number. I have tried my best to write ,but It show me something wrong, What I write is as following, Please help me to show what is going wrong ! Thanks ! Tin Dim N As Integer = CInt(TextBox1.Text) Dim sum As Integer Dim Factorial As Integer Try N = Integer.Parse(TextBox1.Text) sum = N * Factorial(N - 1) Label3.Text = CStr(sum) Catch ex As FormatException MessageBox.Show("Number is not an integer. Please enter an Integer ") End Try End Sub Function Factorial(ByVal N As Integer) As Integer If N = 0 Then Return 1 Else Return N * Factoria((N - 1) - 1) End If End Function Nov 9 '06 #1 