I am working on a simple program to return all factors of a given input integer. Unfortunately I am stuck. THe code is
Dim x As Integer
x = txtInput.Text
Dim factor As Integer
factor = CInt(txtInput.Text) - 1
Dim i As Integer
i = 1
While factor > 0
Do Until i = x
If factor * i = x Then
ListBox1.Items.Add(factor)
i = i + 1
Else
i = i + 1
End If
Loop
factor = factor - 1
End While
x is the input number and i is the increment to see whether it is a factor. factor is a factor.
Can anybody shed some light on where i am going wrong? When it runs it does not appear to do anything. I have stepped into the code and it appears to be running correctly but there is no output.
Thanks for your help!
P.S. I know I have not yet handled outputs which have already been returned.

New Topic/Question
Reply




MultiQuote






|