LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Factorial Function

Okay so I have a label with the ID = lblResult. I want to display
each factorial of 1 through five. But when I run my program it only
displays the value of 5!. Can someone help me put the values of 1! -
4!? I would like it to display as follows:

1
2
6
24
120

or

1, 2, 6, 24, 120

Here is my code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim n, sum As Integer
getFactorial(n, sum)

End Sub
Private Function getFactorial(ByVal n As Integer, ByRef sum As
Integer) As Integer
Dim i As Integer
n = 0
sum = 1
For i = 1 To 5
n = n + 1
sum = n * sum
lblResult.Text = sum
Next i
End Function

Thanks! =)

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Factorial question M.M Excel Worksheet Functions 6 June 8th 09 04:33 PM
Factorial Listing Branson Excel Discussion (Misc queries) 3 June 6th 08 04:18 PM
Factorial (like =FACT) function? mr tom Excel Worksheet Functions 8 June 13th 06 01:45 AM
Range of Factorial Function Rushi Excel Discussion (Misc queries) 7 September 17th 05 12:28 AM
Help? Inverse factorial? 43fan Excel Programming 5 December 30th 03 06:25 PM


All times are GMT +1. The time now is 08:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"