基本形式
```vb
Private Sub Command1_Click()
For i = 1 To 9
For j = 1 To i
Print i & "*" & j & "=" & i * j & " ";
Next j
Next i
End Sub
```
带缩进和对齐的格式
```vb
Private Sub Form_Click()
Me.FontSize = 12
Me.Print Tab(35); "九九乘法表"
Me.Print Tab(35)
For I = 1 To 9
For j = 1 To I
Me.Print Tab((j - 1) * 9 + 1); I & "×" & j & "=" & I * j;
Next j
Next I
End Sub
```
使用Label控件显示九九乘法表
```vb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j, sum As Integer
Dim ts As String
Label1.Text = ""
For i = 1 To 9 Step 1
For j = 1 To 9 Step 1
sum = i * j
ts = i.ToString() & j.ToString() & sum.ToString()
Label1.Text = Label1.Text & ts & Space(10 - Len(ts))
Next
Label1.Text = Label1.Text & vbCrLf
Next
End Sub
```
上三角输出
```vb
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i, j, sum As Integer
For i = 1 To 9
For j = 1 To i
If i = j - 1 Or i = j - 2 Then
' Do nothing
ElseIf i < j Then
' Do nothing
Else
Label1.Text = Label1.Text & j & "×" & i & "=" & i * j & vbCrLf
End If
Next
Next
End Sub
```
这些代码示例展示了如何在Visual Basic中生成九九乘法表,包括基本的循环输出、带缩进和对齐的格式、使用Label控件显示以及上三角输出。你可以根据自己的需求选择合适的代码进行使用。