用VB程序怎么做九九乘法表?
Public Class Form1
Private Sub Button1_Click(sender As Object,e As EventArgs)Handles Button1.Click
Dim i,j As Integer
Dim se As String
Label1.Text=""
For i=1 To 9 Step 1
For j=1 To 9 Step 1
se=i&"x"&j&"="&i*j
Label1.Text&=se&Space(10-Len(se))
Next
Label1.Text&=vbCrLf
Next
End Sub
Private Sub Button2_Click(sender As Object,e As EventArgs)Handles Button2.Click
Dim i,j As Integer
Dim se As String
Label1.Text=""
For i=1 To 9 Step 1
For j=1 To i Step 1
se=i&"x"&j&"="&i*j
Label1.Text&=se&Space(10-Len(se))
Next
Label1.Text&=vbCrLf
Next
End Sub
Private Sub Button3_Click(sender As Object,e As EventArgs)Handles Button3.Click
Dim i,j As Integer
Dim se As String
Label1.Text=""
For i=1 To 9 Step 1
For j=i To 9 Step 1
se=i&"x"&j&"="&i*j
Label1.Text&=se&Space(10-Len(se))
Next
Label1.Text&=vbCrLf&Space(i*10)
Next
End Sub
End Class
扩展资料:
Label定义和用法
<label>标签为input元素定义标注(标记)。
label元素不会向用户呈现任何特殊效果。不过,它为鼠标用户改进了可用性。如果您在label元素内点击文本,就会触发此控件。就是说,当用户选择该标签时,浏览器就会自动将焦点转到和标签相关的表单控件上。
<label>标签的for属性应当与相关元素的id属性相同。
实例
带有两个输入字段和相关标记的简单HTML表单:
<form>
<labelfor="male">Male</label>
<inputtype="radio"name="sex"id="male"/>
<br/>
<labelfor="female">Female</label>
<inputtype="radio"name="sex"id="female"/>
</form>
浏览器支持
所有主流浏览器都支持<label>标签。
Safari 2或更早的版本不支持<label>标签。
提示和注释
注释:"for"属性可把label绑定到另外一个元素。请把"for"属性的值设置为相关元素的id属性的值。
2013-08-18
For i = 1 To 9 Step 1
For j = 1 To i
Print j & "X" & i & "=" & i * j; vbTab;
Next j
Next i
End Sub 效果图:
2013-11-07
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 写的,
2013-11-07
Dim a As Integer
Dim b As Integer
Dim s As String
For a = 1 To 9
For b = 1 To a
s = s & b & "×" & a & "=" & a * b & " "
Next
Print s
s = ""
Next
End Sub 代码很直观,无须解释。
广告 您可能关注的内容 |