Hi,

I don't know why my code isn't working. I've been at it all day but it doesn't work.

I generate 6 numbers at random, called a,b,c,d,e and f.

Another number, x, will equal to (c*e - b*f) divided by (b*d - e*a).

x has to be an integer - no decimal points are allowed.

Anyway, I thought I'd do this by (and logically it should work) using a Do...Loop Until.

Here's what my code should do:

Generate random numbers for a, b, c, d, e and f. Keep generating them until (c*e - b*f) divided by (b*d - e*a) is an integer. Then print a, b, c, d, e, and f, and x, in my picture box.

But this isn't the case! I mean the numbers printed in the picture box don't work out to equal x, when I use the above formula. In fact, nothing seems to work.

I'd appreciate if anybody could tell me what's wrong with my code. Thanks!

_________________

'A command button and picture box

Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim d As Integer
Dim e As Integer
Dim f As Integer


Private Sub Command1_Click()
Picture1.Cls
Do
Randomize

a = -25 + Int(Rnd * 50)
If a = 0 Then
a = a + 1
End If

b = -25 + Int(Rnd * 50)
If b = 0 Then
b = b + 1
End If

c = -25 + Int(Rnd * 50)
If c = 0 Then
c = c + 1
End If

d = -25 + Int(Rnd * 50)
If d = 0 Then
d = d + 1
End If

e = -25 + Int(Rnd * 50)
If e = 0 Then
e = e + 1
End If

f = -25 + Int(Rnd * 50)
If f = 0 Then
f = f + 1
End If

Loop Until c * e - b * f Mod b * d - e * a = 0

Picture1.Print a & " " & b & " " & c & " " & d & " " & e & " " & f & vbCr & _
c * e - b * f / b * d - e * a

End Sub