ImageVerifierCode 换一换
格式:DOCX , 页数:72 ,大小:180.97KB ,
资源ID:29266056      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/29266056.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(VB试验重点章节.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

VB试验重点章节.docx

1、VB试验重点章节3-1 Dim f As Single, c As SingleDim answer As IntegerPrivate Sub Cmdend_Click()Unload MeFrmmain.ShowEnd SubPrivate Sub Cmdhs_Click() f = Val(Txthua.Text) c = (f - 32) * 5 / 9 Txtshe.Text = Str$(c)End SubPrivate Sub Cmdsh_Click() c = Val(Txtshe.Text) If c = 0 Then Txthua.Text = 32 ElseIf c 0

2、Then f = (c * 9# / 5) + 32 Txthua.Text = Str$(f) Else answer = MsgBox(非法数据!, vbOKOnly + vbExclamation, 提示信息) If answer = vbOK Then Txtshe.Text = Txthua.Text = Txtshe.SetFocus End If End IfEnd SubPrivate Sub Label1_Click()End Sub3-2 Option ExplicitDim fs As IntegerPrivate Sub cmdGreat_Click() Text1.T

3、ext = UCase(Text1.Text)End SubPrivate Sub cmdRecall_Click() Text2.Text = Len(Text1.Text)End SubPrivate Sub cmdSmall_Click() Text1.Text = LCase(Text1.Text)End SubPrivate Sub Form_Load()End Sub3-3 Private Sub Form_Click() Dim s1 As Single, s2 As Single, s3 As Single Dim str1 As String, str2 As String

4、Dim b1 As Boolean, b2 As Boolean, b3 As Boolean Dim n1 As Integer, n2 As Integer, n3 As Integer s1 = 18 4 * 4# 2 / 1.6 s2 = 25 3 Mod 3.2 * Int(2.5) str1 = UCase(Xyz) & 1234 & LCase(abC) b1 = 3 4 Or 5 4 b2 = True And False n1 = Int(-3.5) + Fix(3.5) + CInt(2.6) n2 = Len(Str(123) + Hello) s3 = Sgn(7 Mo

5、d 3 - 4) + 0.75 b3 = aeoplane = 1600 Then zgz = gz * (1 + 0.1) ElseIf gz = 1400 Then zgz = gz * (1 + 0.15) Else zgz = gz * (1 + 0.2) End If txtZGz = CStr(zgz)End SubPrivate Sub Command2_Click() txtGz = txtZGz = txtGz.SetFocusEnd Sub4-4 Option ExplicitPrivate Sub Command1_Click() Dim t As Integer, y

6、As Single t = Val(txtTime) If t 10 Then y = 30 ElseIf t 50 Then y = 30 + (t - 10) * 3 Else y = 30 + (t - 10) * 2.5 End If If y = 90 Then Text2.Text = A ElseIf cj = 80 Then Text2.Text = B ElseIf cj = 70 Then Text2.Text = C ElseIf cj = 60 Then Text2.Text = D ElseIf cj = 0 Then Text2.Text = E End IfEnd

7、 SubPrivate Sub Command2_Click()Text1.Text = Text2.Text = End SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Text1_LostFocus()If Not IsNumeric(Text1.Text) Or Val(Text1.Text) 0 ThenMsgBox 数据输入错误,重输Text1.Text = Text1.SetFocusEnd IfEnd Sub4-6 Option ExplicitPrivate Sub Form_Load() Dim Y As Intege

8、r, m As Integer Dim d As Integer, w1 As Integer Dim Rq As Date Dim w2 As String Rq = Date Y = Year(Rq) m = Month(Rq) d = Day(Rq) w1 = Weekday(Rq) Select Case w1 Case 1 w2 = 日 Case 2 w2 = 一 Case 3 w2 = 二 Case 4 w2 = 三 Case 5 w2 = 四 Case 6 w2 = 五 Case 7 w2 = 六 End Select Label1.Caption = 今天是 & Y & 年 &

9、 m & 月 & d & 日 & 星期 & w2End Sub4-7 Private Sub Command1_Click()Dim Y1 As Integer, M1 As IntegerDim flag As Boolean, D1 As Integer, S1 As StringY1 = Val(txtYear)M1 = Val(txtMonth)flag = (Y1 Mod 4 = 0 And Y1 Mod 100 0) Or Y1 Mod 400 = 0Select Case M1Case 1, 2, 3 D1 = 31: S1 = 一季度 If M1 = 2 Then If fla

10、g Then D1 = 29 Else D1 = 28 End If End IfCase 4, 5, 6 D1 = 30: S1 = 二季度If M1 = 5 Then D1 = 31Case 7, 8, 9 D1 = 31: S1 = 三季度If M1 = 9 Then D1 = 30Case 10, 11, 12 D1 = 31: S1 = 四季度If M1 = 11 Then D1 = 30End SelectIf flag Then txtRun = 是闰年 Else txtRun = 不是闰年 End IftxtSea = S1txtDays = Str(D1)End SubPri

11、vate Sub Command2_Click()txtYear = txtMonth = txtSea = txtRun = txtDays = End Sub4-8 Private Sub Cmdclear_Click() txta.Text = Txtb.Text = Txtc.Text = Txtx1.Text = Txtx2.Text = txta.SetFocusEnd SubPrivate Sub Cmdcup_Click() a = Val(txta.Text) b = Val(Txtb.Text) c = Val(Txtc.Text) disc = b * b - 4 * a

12、 * c p = -b / (2 * a) q = Sqr(Abs(disc) / (2 * a) If disc = 0 Then Txtx1 = Format$(p + q, #0.#) Txtx2 = Format$(p - q, #0.#) Else Txtx1 = Str$(p) & + & Str$(q) & i Txtx2 = Str$(p) & - & Str$(q) & i End IfEnd SubPrivate Sub Cmdend_Click() EndEnd SubPrivate Sub txta_KeyPress(KeyAscii As Integer)If Key

13、Ascii = 13 Then If Not IsNumeric(txta.Text) Then MsgBox 数据非法,重输 txta.Text = txta.SetFocus Else Txtb.SetFocus End If End If End SubPrivate Sub Txtb_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If Not IsNumeric(Txtb.Text) Then MsgBox 数据非法,重输 Txtb.Text = Txtb.SetFocus Else Txtc.SetFocus End If En

14、d IfEnd SubPrivate Sub Txtc_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If Not IsNumeric(Txtc.Text) Then MsgBox 数据非法,重输 Txtc.Text = Txtc.SetFocus Else Cmdcup.SetFocus End If End IfEnd Sub4-9 Private Sub Cmdclear_Click()txtm1 = txtm2 = txtm3 = Lblinfo.Caption = txtm1.SetFocusEnd SubPrivate Sub

15、 Cmdsort_Click() Dim m1 As Integer, m2 As Integer, m3 As Integer m1 = Val(txtm1.Text) m2 = Val(txtm2.Text) m3 = Val(txtm3.Text) If (m1 + m2 + m3) 3 95 Or (m1 = 100 And m2 = 100 And m3 = 80) _ Or (m1 = 100 And m3 = 100 And m2 = 80) Or _ (m1 = 80 And m2 = 100 And m3 = 100) Then Lblinfo.Caption = 此学生奖学

16、金为一等奖 ElseIf (m1 + m2 + m3) 3 90 Or (m1 = 100 And m2 = 75 And m3 = 75) _ Or (m1 = 75 And m2 = 100 And m3 = 75) Or _ (m1 = 75 And m2 = 75 And m3 = 100) Then Lblinfo.Caption = 此学生奖学金为二等奖 ElseIf m1 = 70 And m2 = 70 And m3 = 70 Then Lblinfo.Caption = 此学生奖学金为三等奖 Else Lblinfo.Caption = 此学生无奖学金 End IfEnd S

17、ubPrivate Sub txtm1_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If Not IsNumeric(txtm1) Then MsgBox 数据非法,重新输入, vbExclamation, 输入操作数1 txtm1.Text = txtm1.SetFocus Else txtm2.SetFocus End IfEnd IfEnd SubPrivate Sub txtm2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If Not IsNumeric(txtm2)

18、Then MsgBox 数据非法,重新输入, vbExclamation, 输入操作数2 txtm2.Text = txtm2.SetFocus Else txtm3.SetFocus End IfEnd IfEnd SubPrivate Sub txtm3_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then If Not IsNumeric(txtm3) Then MsgBox 数据非法,重新输入, vbExclamation, 输入操作数3 txtm3.Text = txtm3.SetFocus Else Cmdsort.SetFocus

19、End IfEnd IfEnd Sub5-1 Option Explicit方法一:用三重循环,将三个一位数合并成一个三位数Private Sub Form_Click()Dim i As Integer, j As Integer, k As IntegerFor i = 1 To 9 For j = 0 To 9 For k = 0 To 9 If i * 100 + j * 10 + k = i 3 + j 3 + k 3 Then Print Str$(i * 100 + j * 10 + k); End If Next k Next j Next iEnd Sub 方法二:用一重循环

20、,将一个三位数分离为三个一位数Private Sub Form_Click() Dim n As Integer Dim i As Integer, j As Integer, k As Integer For n = 100 To 999 i = n Mod 10 j = (n 10) Mod 10 k = n 100 If n = i 3 + j 3 + k 3 Then Print Str$(n); Next nEnd Sub5-2 Private Sub Command1_Click() Dim n As Integer, i As Integer, s As String, sum

21、As Integer For n = 1 To 1000 sum = 0 s = Str(n) + = For i = 1 To n 2 If n Mod i = 0 Then sum = sum + i s = s + Str(i) + + End If Next i If n = sum Then s = Left(s, Len(s) - 1) Picture1.Print s End If Next nEnd SubPrivate Sub Command2_Click() EndEnd Sub5-3 Private Sub Form_Click()Dim n As Integer, x0 As Single, x1 As Single, sum!, x!x = Val(Text1.Text)n = 1sum = 1x1 = 1Do x0 = x1 x1 = x0 * x / n sum = sum + x1 n = n + 1Loop Until x1 0.000001 Print sumEnd Sub5-4 Private Sub cmdClear_Click() txt1.Text = txt2.Text = txt1.SetFocusEnd Sub

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1