Dim Num1 As Long
Dim sum1 As Long
Dim count1 As Integer
Dim Divisor1list As String
If KeyAscii = 13 Then
Num1 = Val(txtNum1.Text)
sum1 = 0
count1 = 0
Divisorlist = ""
For Divisor1 = 1 To Num1
If Num1 Mod Divisor1 = 0 Then
sum1 = sum1 + Divisor1
Divisor1list = Divisor1list & Str$(Divisor1) & " "
lblSum1.Caption = sum1
End If
Next Divisor1
txtDivisor1List.Text = Divisor1list
For count1 = 1 To Divisor1
count1 = count1 + 1
lblcount1.Caption = count1
Next
lblcount1 = count1
End if
- - - - - -
I'm stuck with writing a program that would count a list of factors a number would have. I thought that I could do at first an If-Test for prime numbers since the count would always be 2 yet I have no idea how to code for numbers that aren't prime. I been playing around with the 'For count1 = 1 to _____ ' by changing Divisor1 into my other listed variables as well as changing the arithmetic 'count1= ____ + 1' but I've been getting weird totals.
Am I missing another variable that I should be using or?
Dim sum1 As Long
Dim count1 As Integer
Dim Divisor1list As String
If KeyAscii = 13 Then
Num1 = Val(txtNum1.Text)
sum1 = 0
count1 = 0
Divisorlist = ""
For Divisor1 = 1 To Num1
If Num1 Mod Divisor1 = 0 Then
sum1 = sum1 + Divisor1
Divisor1list = Divisor1list & Str$(Divisor1) & " "
lblSum1.Caption = sum1
End If
Next Divisor1
txtDivisor1List.Text = Divisor1list
For count1 = 1 To Divisor1
count1 = count1 + 1
lblcount1.Caption = count1
Next
lblcount1 = count1
End if
- - - - - -
I'm stuck with writing a program that would count a list of factors a number would have. I thought that I could do at first an If-Test for prime numbers since the count would always be 2 yet I have no idea how to code for numbers that aren't prime. I been playing around with the 'For count1 = 1 to _____ ' by changing Divisor1 into my other listed variables as well as changing the arithmetic 'count1= ____ + 1' but I've been getting weird totals.
Am I missing another variable that I should be using or?