在一个程序里了: clear SET TALK OFF FOR i=1 TO 9 FOR j=1 TO i ?? str(j,2)+"*"+STR(i,2)+"="+str(i*j,2) NEXT ? NEXT ? FOR i=9 TO 1 step -1 FOR j=1 TO i ?? str(j,2)+"*"+STR(i,2)+"="+str(i*j,2) NEXT ? NEXT FOR i=9 TO 1 step -1 ? SPACE(8*(9-i)) FOR j=1 TO i ?? str(j,2)+"*"+STR(i,2)+"="+str(i*j,2) NEXT NEXT ? FOR i=1 TO 9 ? SPACE(8*(9-i)) FOR j=1 TO i ?? str(j,2)+"*"+STR(i,2)+"="+str(i*j,2) NEXT NEXT SET TALK ON
Private Sub Form_click()
Dim i As Integer, j As Integer
For i = 1 To 9
For j = i To 9
Print i; "*"; j; "="; i * j; " ";
Next j
Print
Next i
End Sub
for嵌套循环,如有问题,请追问是这个吗?
Private Sub Form_Click()
Dim a%, b%
For a = 1 To 9
For b = 1 To a
Print a & "x" & b & "=" & a * b,
Next b
Print
Next a
End Sub
Private Sub Command1_Click()
Dim I, J As Integer
For I = 1 To 9
For J = I To 9
Print J & "*" & I & "=" & CStr(I * J) & Space(2);
Next J
Print
Next I
End SubPrivate Sub Form_Click()
Print Tab(35); "乘法表"
Dim Se As String
For I = 1 To 9
For J = 1 To I
Se = I & "X" & J & "=" & I * J
Print Tab((J - 1) * 9); Se;
Next J
Print
Next I
End Sub
(1)print"*" 意思是打印一个字符"*"。(2)print:print VB中,一行一句命令,如果你想多句命令一行,可用冒号隔开。 print省略参数就表示输出一个空行。 简单说,"print:print"就等于: print print 打印两行空行。(3)tab(n)函数。 用来将光标移到参数n指定的位置开始输出信息。tab(i*6),(i=1,2,3...),也就是在第6、12、24...格才输出表达式,这样看起来就像一个列表一样。如果你需要更要宽松一点,你写成tab(i*7)也是可以的:) 楼主提供的程序代码,语句有点混乱,运行也不正确. 请参考我提供的以下的乘法表(思路清晰):Private Sub Form_Click()Print Tab(35); "乘法表"Dim Se As StringFor I = 1 To 9 For J = 1 To I Se = I & "X" & J & "=" & I * J Print Tab((J - 1) * 9); Se; Next J PrintNext IEnd Sub代码给你,其它背景字体什么的都是小问题private sub command1_click() dim i as integer,j as integer for i = 1 to 9 for j = 1 to i print j & "x " & i & "= " & i * j & vbtab; next print nextend sub两个print是输出两个空行,“print "*"”是输出乘号,tab那个就是几个空格还是试一下我这个九九乘法口诀表吧比较简洁For a = 1 To 9 jgstr = "" For b = 1 To a jgstr = jgstr & b & " × " & a & "=" & a * b & vbTab Next Print jgstrNext