VB程序设计九九乘法表编写,求高手解答,非常感谢!

VB程序设计九九乘法表编写,求高手解答,非常感谢!
2024-12-04 16:56:50
推荐回答(2个)
回答(1):

我下面给你的这个代码是包括正三角打印乘法表和倒三角打印的……

Private Sub Command1_Click()
Dim se As String
Print Tab(35); "九九乘法表"
Print Tab(35); "-----------"
For i = 1 To 9
For j = 1 To i
se = i & "×" & j & "=" & i * j 'se字符串变量存放每一项表达式
Print Tab((j - 1) * 9 + 1); se; ' 每项表达式显示占9列
Next j
Print '换行
Next i
End Sub

Private Sub Command2_Click()
Dim se As String
Print Tab(35); "九九乘法表"
Print Tab(35); "-----------"
For i = 1 To 9
For j = i To 9
se = i & "×" & j & "=" & i * j 'se字符串变量存放每一项表达式
Print Tab((j - 1) * 9 + 1); se; ' 每项表达式显示占9列
Next j
Print '换行
Next i
End Sub

Private Sub Command3_Click()
Me.Cls
End Sub

回答(2):

Private Sub Form_Click()
For i = 1 To 9
For j = 1 To i
Print j; "*"; i; "="; i * j;
If j = 2 And (i = 3 Or i = 4) Then
Print " ";
End If
Next j
Print
Next i
End Sub