VB,怎么在文本框中输出九九乘法表,最好是三角的
展开全部
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
For i = 1 To 9
For j = 1 To 9
If i <= j Then TextBox1.Text = TextBox1.Text & i & "x" & j & "=" & (i * j) & Chr(9)
Next
TextBox1.Text = TextBox1.Text & Chr(13) & Chr(10)
Next
End Sub
End Class
关键在于 Chr() 函数,VS 2008 写的,
还要现做现卖……原样拷过来的,看看能不能用。累……
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
For i = 1 To 9
For j = 1 To 9
If i <= j Then TextBox1.Text = TextBox1.Text & i & "x" & j & "=" & (i * j) & Chr(9)
Next
TextBox1.Text = TextBox1.Text & Chr(13) & Chr(10)
Next
End Sub
End Class
关键在于 Chr() 函数,VS 2008 写的,
还要现做现卖……原样拷过来的,看看能不能用。累……
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim i, k, z As Short
Dim bb As String = ""
If Len(Label2.Text) = 0 Then
For i = 1 To 9
For k = 1 To 9
z = i * k
bb = bb & Str(k) & "x" & Str(i) & "=" & Str(z) & Space(2)
If i = k Then
bb = bb & vbCrLf
Exit For
End If
Next
Next
Label2.Text = bb & Label2.Text
Else
Exit Sub
End If
End Sub
Dim i, k, z As Short
Dim bb As String = ""
If Len(Label2.Text) = 0 Then
For i = 1 To 9
For k = 1 To 9
z = i * k
bb = bb & Str(k) & "x" & Str(i) & "=" & Str(z) & Space(2)
If i = k Then
bb = bb & vbCrLf
Exit For
End If
Next
Next
Label2.Text = bb & Label2.Text
Else
Exit Sub
End If
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |