Convert qBASIC to VBA

in VBA
I am converting some QB code to VBA. Everything works except for converting the following lines of QB code -

FOR I = 1 TO A
IF B(I) > 0 THEN
PRINT "("; C(I); "="; B(I); ")";
END IF
NEXT I

These lines screen print the results of part of the programme could look like, for example for an "I" of 4 -

( 1749 = 1 )( 1542 = 1 )( 717 = 2)( 1774 = 1)

What I want to do with VBA is to have the results enter into an Excel cell as text. The best I can come up with is -

For I = 1 To A
If B(i) > 0 Then
result = C(I) & " x " & B(I)
End If
Next I
Cells(40 + d, 81) = result
d = d + 1

where "result" is defined as a string. The problem is that I only get the last entry ie. 1774 = 1 so it appears that the others in the loop are overwritten. Can anyone help? The semi-colons seem to be the problem but I can't find an equivalent in VBA.

Thankyou
Peter

• your problem can be handled by using the FOR I counter to increment the Cell to store your result

[code]
For I = 1 To a
If b(I) > 0 Then
result = c(I) & " x " & b(I)
End If
'Cells(40 + I, 81) = result '**STORE IN YOUR COLUMN
Cells(I, 1) = result '**STORE RESULT IN COLUMN A1-
Next I

OR

For I = 1 To a
If b(I) > 0 Then
result = c(I) & " x " & b(I)
End If
Cells(40 + d, 81) = result '**STORE IN YOUR COLUMN
d = d + 1
Next I

[/code]
• : your problem can be handled by using the FOR I counter to increment
: the Cell to store your result
:
: [code]:
: For I = 1 To a
: If b(I) > 0 Then
: result = c(I) & " x " & b(I)
: End If
: 'Cells(40 + I, 81) = result '**STORE IN YOUR COLUMN
: Cells(I, 1) = result '**STORE RESULT IN COLUMN A1-
: Next I
:
: OR
:
: For I = 1 To a
: If b(I) > 0 Then
: result = c(I) & " x " & b(I)
: End If
: Cells(40 + d, 81) = result '**STORE IN YOUR COLUMN
: d = d + 1
: Next I
:
: [/code]:

Thanks for your reply, you put me back on the right track. I used another counter to prevent movint the cell when b is not gteater than zero ie. b = 0. The final code is

e = 0
For i = 1 To a
If b(i) > 0 Then
result = c(i) & " x " & b(i)
Cells(40 + d, 81 + e) = result
If besteachtype = 0 Then e = e + 1
End If
Next i
d = d + 1
• : : your problem can be handled by using the FOR I counter to increment
: : the Cell to store your result
: :
: : [code]: :
: : For I = 1 To a
: : If b(I) > 0 Then
: : result = c(I) & " x " & b(I)
: : End If
: : 'Cells(40 + I, 81) = result '**STORE IN YOUR COLUMN
: : Cells(I, 1) = result '**STORE RESULT IN COLUMN A1-
: : Next I
: :
: : OR
: :
: : For I = 1 To a
: : If b(I) > 0 Then
: : result = c(I) & " x " & b(I)
: : End If
: : Cells(40 + d, 81) = result '**STORE IN YOUR COLUMN
: : d = d + 1
: : Next I
: :
: : [/code]: :
:
: Thanks for your reply, you put me back on the right track. I used
: another counter to prevent movint the cell when b is not gteater
: than zero ie. b = 0. The final code is
:
: e = 0
: For i = 1 To a
: If b(i) > 0 Then
: result = c(i) & " x " & b(i)
: Cells(40 + d, 81 + e) = result
: If a = 0 Then e = e + 1
: End If
: Next i
: d = d + 1
: