Hi Guys,

I am new to using Visual Basic. (I am using VB 6)

I am wanting to create a simple program that solves equations in the form

A(x) + B(y) = C

Where A, B and C have already been inputted into text boxes.

Ideally the program would start with a y value of -500, and then try x = -500, -499, - 498 etc etc until it reached 500.
Then y would increase by 1 and try all the x values again, and so on. If anything matches the value of C, it would all be added to a List Box.

Here is the code I have put together (forgive me if the syntax is horrendous!)

**I have three input text boxes, a list box and a command button.**




Private Sub Command1_Click()
Dim a As Variant, b As Variant, c As Variant, x As Variant, y As Variant

a = Text1
b = Text2
c = Text3

For y = -500 To 500

For x = -500 To 500
If (a * x) + (b * y) = c Then
List1.AddItem Trim$(a) + Trim$(x) + "+" + Trim$(b) + Trim$(y) + "=" + Trim(c)
x = x + 1
Loop

y = y + 1
End If
Loop

End Sub




I am getting a lot of 'loop without do' errors. However If I place a 'do' at the top of each loop it seems to make no difference.
Is it an issue that I have a loop system within another loop? (i'm not really sure how else I would do this problem)

Any help would be much appreciated.

Cheers Guys,
Phil