Skip to main content

How to Get Factorial Numbers in VB.Net

This time, let’s learn how to get factorial numbers in VB.Net. If we say factorial number, it means a number which is multiply itself to its decreasing numbers and it is denoted by the symbol (!). Like for example the factorial number or value of 5. This is how it looks like, 5! = 5 x 4 x 3 x 2 x 1 = 120. Now, let’s try doing this with codes in VB.Net. Just simply follow the instructions below.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form application. factorial23

Step 2

Add the Label, Button and a TextBox inside the Form. factorial1234

Step 3

Double click the button and do the following code inside the sub procedure for getting factorial numbers.
  1. Dim n, f, i As Integer
  2. f = 1
  3. n = Val(TextBox1.Text)
  4. For i = 1 To n
  5. f = f * i
  6. Next
  7. MsgBox(“Factorial is :” & f, vbInformation, “Factorial”)
For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT FB Account – Or feel free to comment below.


Submitted byMary O'Brien (not verified)on Sat, 05/01/2021 - 05:13

Please do not use Val in code. The entry should be parsed for correctness.

Add new comment