- 1、本文档共14页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
孙俏版VB6-7章答案
6.1编码
Private Sub div(x As Integer)
If x Mod 2 = 0 Then
MsgBox x 是偶数
Else
MsgBox x 是奇数
End If
End Sub
Private Sub Command1_Click()
Call div(Text1.Text)
End Sub
6.2
编码
Private Sub div(a As Integer, b As Integer)
For I = a To b
For J = 2 To I - 1
If I Mod J = 0 Then
Exit For
End If
Next J
If J = I Then
Sum = Sum + I
End If
Next I
Text1.Text = Sum
End Sub
Private Function GDC(a As Integer, b As Integer) As Integer
For I = a To b
For J = 2 To I - 1
If I Mod J = 0 Then
Exit For
End If
Next J
If J = I Then
Sum = Sum + I
GDC = Sum
End If
Next I
Text1.Text = GDC
End Function
Private Sub Command1_Click()
Call GDC(100, 200)
End Sub
Private Sub Command2_Click()
Call div(200, 400)
End Sub
6.3
编码
Private Function GDC(a As Integer, b As Integer) As Integer
Dim t%
If a b Then t = a: a = b: b = t
t = a Mod b
Do While t 0
a = b: b = t
t = a Mod b
Loop
GDC = b
Text3.Text = GDC
End Function
Private Sub Command1_Click()
Call GDC(Text1.Text, Text2.Text)
End Sub
6.4
编码
Private Function sum(x() As Integer) As Integer
Dim i As Integer
For i = LBound(x) To UBound(x)
sum = sum + x(i)
Next i
End Function
Private Sub Command1_Click()
Dim j As Integer
Dim a(1 To 10) As Integer
For j = 1 To 10
a(j) = Val(InputBox(请输入第 j 个数))
Next j
s = sum(a())
Text1.Text = s
End Sub
7.1
编码
Private Sub Command1_Click() 开始
Timer1.Enabled = True
End Sub
Private Sub Command2_Click() 停止
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Label1.Caption = 欢迎使用Visual Basic
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Top = Label1.Top + 100
If Label1.Top Height Then Label1.Top = -Label1.Height
End Sub
7.2
编码
Private Sub Form_Load()
VScroll1.Max = 2800
VScroll1.Min = 0
End Sub
Private Sub VScroll1_Change()
Label1.Top = VScroll1.Value + 100
End Sub
7.3
编码
Private S
文档评论(0)