| | |
Factorial of N
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2008
Posts: 65
Reputation:
Solved Threads: 4
I really dont know this Program is rite or wrong. but it wont give a answer. if anyone can help me in this
Public Class Form2
Dim num As Integer
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fact As Integer
num = Val(InputBox("Enter the Factorial Number"))
Do
fact = fact * num
num = num - 1
Loop Until num <= 0
MessageBox.Show(fact)
End Sub
End Class
Public Class Form2
Dim num As Integer
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim fact As Integer
num = Val(InputBox("Enter the Factorial Number"))
Do
fact = fact * num
num = num - 1
Loop Until num <= 0
MessageBox.Show(fact)
End Sub
End Class
use this following function :
I called this function in button click event:
vb.net Syntax (Toggle Plain Text)
Public Function Factorial(ByVal Number As Integer) As String Try If Number = 0 Then Return 1 Else Return Number * Factorial(Number - 1) End If Catch ex As Exception Return ex.Message End Try End Function
vb.net Syntax (Toggle Plain Text)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim num As Integer num = Val(InputBox("Enter the Factorial Number")) MsgBox(Factorial(num)) End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Similar Threads
- factorial using a for loop (C++)
- Factorial? (C++)
- Factorial program (Java)
- Calculate the factorial of a number (Visual Basic 4 / 5 / 6)
Other Threads in the VB.NET Forum
- Previous Thread: Popup Form Refresh combobox on parent form
- Next Thread: Positioning an image using Excel
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add arithmetic array assignment basic binary bing box button buttons center code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel file-dialog firewall folder google hardcopy image images isnumericfuntioncall listview login math memory mobile ms msaccess mssqlbackend mysql navigate net networking opacity output pan peertopeervideostreaming picturebox picturebox1 plugin port print printpreview problemwithinstallation project record reports" reuse save savedialog serial sorting sql storedprocedure string temp text textbox timer toolbox updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf






