Finding Factors Program in VB6
Submitted by donbermoy on Wednesday, March 26, 2014 - 21:45.
Factor is a a number or quantity that when multiplied with another produces a given number or expression. In this article, we will create a program that an find factors of a number input by the user and display them in a list box.
Now, let's start this tutorial!
1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open.
2. Next, add two Buttons named Command1 labeled it as "Find Factor" and Command1 labeled as "Clear". Add one textbox named Text1 for inputting the desired number and insert also a listview named List1 for displaying the list of numbers divisible by the inputted number in the textbox. You must design your interface like this:
3. Now put this code for your code module.

- Private Sub Command1_Click()
- Dim strInt, x As Integer
- strInt = Val(Text1.Text)
- For x = 2 To strInt - 1
- If strInt Mod x = 0 Then
- List1.AddItem (x)
- End If
- Next
- List1.AddItem (strInt)
- End Sub
- Private Sub Command2_Click()
- Text1.Text = ""
- List1.Clear
- End Sub