0
votes

ok so im trying to do an assignment and i have written this code but it has errors, and i cant see why.

its saying expected statement, and im looking over it and i cant find what the problem is. Would be amazing if someone could shed some light on the error and possibly help me out.

here is the do until statement:

Sub btnTransformY_onclick()
    Do Until r = 4 And n = 3
        Do Until m = 1 To 8
            Change(r,c) = (transformationY(r,1) * meh(1, m)) + transformationY(r, 2) * meh(2,m) + TransformationY(r,3) * meh(3,m)  
            m = m + 1
        Next

        c = c + 1
        If c = 8 Then r = r + 1 And c = 1
    Next
End Sub

unfortunately this hasnt worked, although it does seem to be the Do Until m = 1 To 8 does anyone know if to is valid syntax for a do until loop?

2
Do Until m = 1 To 8 is an invalid statement. You're getting your error when it reaches the To keyword. - Nilpo
Please don't vandalize your question, even if you now think it was stupid. You had this problem and came here to solve it. Someone else might have the same problem and will be glad to see there is a solution. - Geert Bellekens

2 Answers

1
votes

I reckon you want something on these lines, except I suspect you want two Next loops for r and n rather than one Do Until.

Sub btnTransformY_onclick()
    r = 0
    n = 0

    Do Until r = 4 And n = 3
        For m = 1 To 8
            Change(r,c) = (transformationY(r,1) * meh(1, m)) + transformationY(r, 2) * meh(2,m) + TransformationY(r,3) * meh(3,m)  
            ''m = m + 1
        Next

        c = c + 1
        If c = 8 Then 
            r = r + 1 
            c = 1
            ''Where does n get counted up?
        End If
    Loop
End Sub
0
votes

Next is for for loops, to close a do loop use loop:

do until ..
  ...
loop

Also

if c = 8 then r = r + 1 and c = 1

Is a bitwise comparison (bits of LHS anded with RHS) which is probably not what you want, so instead;

if c = 8 then 
   r = r + 1 
   c = 1
end if