孙俏版VB6-7章答案_第1页
孙俏版VB6-7章答案_第2页
孙俏版VB6-7章答案_第3页
孙俏版VB6-7章答案_第4页
孙俏版VB6-7章答案_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、6.1编码Private Sub div(x As Integer)If x Mod 2 = 0 ThenMsgBox x & 是偶数ElseMsgBox x & 是奇数End IfEnd SubPrivate Sub Command1_Click()Call div(Text1.Text)End Sub6.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 = Su

2、m + I End If Next I Text1.Text = SumEnd SubPrivate Function GDC(a As Integer, b As Integer) As IntegerFor 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 FunctionPrivate Sub Command1_Click()Call GDC(100

3、, 200)End SubPrivate Sub Command2_Click()Call div(200, 400)End Sub6.3编码Private Function GDC(a As Integer, b As Integer) As IntegerDim t%If a b Then t = a: a = b: b = tt = a Mod bDo While t 0 a = b: b = t t = a Mod bLoopGDC = bText3.Text = GDCEnd FunctionPrivate Sub Command1_Click()Call GDC(Text1.Tex

4、t, Text2.Text)End Sub64编码Private Function sum(x() As Integer) As IntegerDim i As IntegerFor i = LBound(x) To UBound(x)sum = sum + x(i)Next iEnd FunctionPrivate Sub Command1_Click()Dim j As IntegerDim a(1 To 10) As IntegerFor j = 1 To 10a(j) = Val(InputBox(请输入第 & j & 个数)Next js = sum(a()Text1.Text =

5、sEnd Sub7.1编码Private Sub Command1_Click() 开始Timer1.Enabled = TrueEnd SubPrivate Sub Command2_Click() 停止Timer1.Enabled = FalseEnd SubPrivate Sub Form_Load()Label1.Caption = 欢迎使用Visual BasicTimer1.Interval = 100Timer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer()Label1.Top = Label1.Top + 100If Labe

6、l1.Top Height Then Label1.Top = -Label1.HeightEnd Sub7.2编码Private Sub Form_Load()VScroll1.Max = 2800VScroll1.Min = 0End SubPrivate Sub VScroll1_Change()Label1.Top = VScroll1.Value + 100End Sub7.3编码Private Sub Form_Load()Timer1.Interval = 5000End SubPrivate Sub Timer1_Timer()Form1.HideForm2.ShowTimer

7、1.Enabled = FalseEnd Sub7.4编码Private Sub Command1_Click() Dim str As String str = 我的爱好是:If Check1.Value = 1 Thenstr = str & Check1.CaptionEnd IfIf Check2.Value = 1 Thenstr = str & Check2.CaptionEnd IfIf Check3.Value = 1 Thenstr = str & Check3.CaptionEnd IfPrint strEnd Sub7.5Dim a As IntegerPrivate S

8、ub Command1_Click()For i = 0 To 5If Check1(i).Value = 1 Thena = a + 1End IfNext iMsgBox 有 & a & 个复选框被选End Sub7.6编码Private Sub Command1_Click()For i = o To 2If List1.Selected(i) ThenList2.AddItem List1.List(i)End IfNext iFor i = o To 1If Option1(i).Value = True ThenList2.AddItem Option1(i).CaptionEnd

9、 IfNext iFor i = o To 2If Option2(i).Value = True ThenList2.AddItem Option2(i).CaptionEnd IfNext iFor i = 0 To 2If Check1(i).Value = 1 ThenList2.AddItem Check1(i).CaptionEnd IfNext iEnd SubPrivate Sub Form_Load()With cmbsell.AddItem 求购.AddItem 转让.AddItem 交换Text = .List(0)End WithWith List1.AddItem 电

10、影票.AddItem 演唱会门票.AddItem 健身卡.AddItem 教材.AddItem 小说杂志.AddItem 音像制品.AddItem 自行车.AddItem 电动自行车End WithEnd SubPrivate Sub cmbsell_Click()txttitle.Text = cmbsell.TextEnd SubPrivate Sub List1_Click()Item = List1.Texttxttitle.Text = cmbsell.Text & List1.TextEnd SubPrivate Sub optftf_Click()txtprice.Enabled = Falsetxttitle.Text = cmbsell.Text & List1.Text & ,价格面议End SubPrivate Sub optprice_Click()txtprice.Enabled = turetxttitle.Text = cmbsell.Text & List1.Text & ,价格End SubPrivate Sub txtprice_Change()txttitle.Text = cmbsell.Text & List1.Text & ,价格 & txtprice.Text & 元End Sub

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论