what is the fastest way to make a multiplication table with less than 10 lines of code.
Printable View
what is the fastest way to make a multiplication table with less than 10 lines of code.
This really isn't aligned well, but it demonstrates the basic idea. Add this code to a Form with a Label. Set the Font to a fixed width font (such as Courier New).
Code:For X = 1 To 10
For Y = 1 To 10
Label1 = Label1 & " " & X * Y
Next Y
Label1 = Label1 & vbCrLf
Next X
Actually, use the following instead. You don't need a Label and it's perfectly aligned.
Again, remember to use a Fixed With font.
Code:For X = 1 To 10
For Y = 1 To 10
If (X * Y) < 10 Then Print " " & (X * Y) & " ";
If (X * Y) >= 10 Then Print " " & (X * Y) & " ";
Next Y
CurrentX = 0
CurrentY = CurrentY + 240
Next X
Thanks Meg, but I forgot to mention that I also need it to start off with a zero.
Instead of making it start from 1, make it start from 0.
Code:For X = 0 To 10
For Y = 0 To 10
If (X * Y) < 10 Then Print " " & (X * Y) & " ";
If (X * Y) >= 10 Then Print " " & (X * Y) & " ";
Next Y
CurrentX = 0
CurrentY = CurrentY + 240
Next X