dim A as string, num1 as integer, num2 as integer
num1=1
num2=num*2
for num1=1 to 10 sep num2
A=A & str(num1+num2)
next num1
SOLVE A
in this problem, what exactly is A=A & str(num1+num2)?
Printable View
dim A as string, num1 as integer, num2 as integer
num1=1
num2=num*2
for num1=1 to 10 sep num2
A=A & str(num1+num2)
next num1
SOLVE A
in this problem, what exactly is A=A & str(num1+num2)?
I'll explain it to you:
Dim A As String, Num1 As Integer, Num2 As Integer
Num1 = 1 ' Sets 1 to variable Num1
Num2 = Num1 * 2 ' Sets a value two times bigger than Num1 to Num2 (this would be 2)
For Num1 = 1 To 10 Step Num2 ' Loops Num1 from 1 to 10, stepping (Num2) ahead each time
A = A & Str(Num1 + Num2) ' Adds Num1 to Num2, and puts the result in the end of string A
Next Num1 ' Goes back to beginning of loop
In the end, A should contain " 3 5 7 9 11". If you want to remove the spaces, then use Trim(Str(Num1 + Num2)) instead of Str(Num1 + Num2). The result would be "357911". On second thought... Leave the spaces...
------------------
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
[This message has been edited by Yonatan (edited 11-09-1999).]
It concatenates (joins together) the value of A with the sum of num1 plus num2 converted to a string. If you put a Msgbox A line following the line, you will see the result.
------------------
Marty
Shame on you Yonatan! You were doing good until you told him what the final value of A is. It looks to me as if you just answered someone's homework question! :)
so, the way I see it/ the result should be as follows:
num1 num2=num1*2 num1+num2
1 2 3
3 6 9
5 10 15
7 14 21
9 18 27
therefore the answer is: 39152127. Is this correcr?