2015《Visual BASIC程序设计》期末考试编程题复习答案.doc
文本预览下载声明
1
Private Sub Command1_Click()
Label1.ForeColor = vbRed
Label1.Caption = quot;颜色已经改变quot;
End Sub
Private Sub Command2_Click()
Label1.FontName = quot;黑体quot;
End Sub
4
Private Sub Command1_Click()
Dim n%, a%, b%, c%
n = Val(Text1.Text)
a = n \ 100
b = (n - a * 100) \ 10
c = n Mod 10
Label1.Caption = quot;百位数:quot; amp; a amp; quot;,十位数:quot; amp; b amp; quot;,个位数quot; amp; c End Sub
5
Private Sub Command1_Click()
Label1.Caption = quot;+quot;
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
Private Sub Command2_Click()
Label1.Caption = quot;-quot;
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub
Private Sub Command3_Click()
Label1.Caption = quot;*quot;
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub
Private Sub Command4_Click()
Label1.Caption = quot;/quot;
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub
Private Sub Command5_Click()
Text1.Text = quot;quot;
Text2.Text = quot;quot;
Text3.Text = quot;quot;
End Sub
Private Sub Command6_Click()
End
End Sub
6
Private Sub Form_Load()
Dim djamp;, shL%, jeamp;
dj = Val(InputBox(quot;输入某品牌电脑的单价;quot;))
shL = Val(InputBox(quot;输入某品牌电脑的的购买的数量;quot;)) je = dj * shL
MsgBox quot;需付款金额;quot; amp; je
End Sub
7
Private Sub Form_Click()
Dim zh%
Randomize
zh = Int(90 * Rnd) + 10
MsgBox quot;两位的随机整数是:quot; amp; zh
End Sub
8
Private Sub Command1_Click()
Dim hh%, mm%, ss%, totals!
Dim outstr$
hh = Val(Text1)
mm = Val(Text2)
ss = Val(Text3)
totals = hh * 3600 + mm * 60 + ss
outstr = hh amp; quot;小时quot; amp; mm amp; quot;分 quot; amp; ss amp; quot;秒quot; outstr = outstr amp; vbCrLf amp; quot;总计:quot; amp; totals amp; quot;秒quot; MsgBox outstr, , quot;输出结果quot;
End Sub
Private Sub Command2_Click()
End
End Sub
9
Private Sub Command1_Click()
Dim r!, k!, s!
r = Val(InputBox(quot;请输入圆的半径quot;, quot;计算圆的周长和面积quot;)) k = 2 * 3.14159 * r
s = 3.14159 * r * r
Text1.Text = k
Text2.Text = s
msgbox quot;计算已完成!quot;, , quot;计算圆的周长和面积quot; End Sub
Private Sub Command2_Click()
end
End Sub
10
Dim x%, a%
Dim b%, c%
x
显示全部