ImageVerifierCode 换一换
你正在下载:

VB习题.docx

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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

VB习题.docx

1、VB习题Private Sub Option1_Click()Text1.BackColor = vbRedEnd SubPrivate Sub Option2_Click()Text1.BackColor = vbGreenEnd SubPrivate Sub Option3_Click()Text1.BackColor = vbYellowEnd Sub private sub command1_click()dim s as stringdim i,n as integers=n=len(text1.text)*found*请不要删除该行for i=2 to n step 2s=s&mi

2、d(text1.text,i,1)next i*found*请不要删除该行text2.text= S end subprivate sub form_click()dim a(9) as integer,x as integer,k as integer,i as integerrandomizedo while i 0.00001 Then s = s + m Else Exit Do i = i + 1 Loop *end* Print s=; Print Format(s, #.0000); DataWrite (s)End SubSub DataWrite(x As Double) O

3、pen App.Path & & progout.dat For Output As #1 Print #1, s=; Print #1, Format(x, #.0000) Close #1End SubPrivate Sub Check1_Click()Text1.FontBold = TrueEnd SubPrivate Sub Check2_Click()Text1.FontItalic = TrueEnd SubPrivate Sub Check3_Click()Text1.FontUnderline = TrueEnd SubPrivate Sub Command1_Click()

4、 Dim n As Integer n = InputBox(请输入行数n) Cls Print 一共有; n; 行 *found* 请不要删除该行 Call Sub1(n)End SubSub Sub1(n As Integer) Dim i, j For i = 1 To n*found* 请不要删除该行 For j = 1 To i Print i; *; j; =; i * j, Next j Print Next i End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer) If Chr(KeyAscii) = ( Then*fou

5、nd* 请不要删除该行,只在下一行中填空 Count1 = Count1 + 1 ElseIf Chr(KeyAscii) = ) Then Count1 = Count1 - 1 End If If KeyAscii = 13 Then If Count1 = 0 Then Print 左右括号配对*found* 请不要删除该行,只在下一行中填空 ElseIf Count1 0 Then Print 左括号多于右括号; Count1; 个 Else Print 右括号多于左括号; -Count1; 个 End If End IfEnd SubSub Fun(I As Integer, fla

6、g As Integer) flag = 0*begin* Dim s As Integer For j = 1 To Len(Str(I) m = Val(Mid(Str(I), j, 1) s = s + m 3 Next j If s = I Then flag = 1*end*End SubPrivate Sub Command1_Click() Dim I As Integer, flag As Integer Open App.Path & & PROGOUT.DAT For Output As #1 Picture1.Print 水仙花数有: For I = 100 To 999

7、 Call Fun(I, flag) If flag = 1 Then Picture1.Print I If flag = 1 Then Print #1, I & 是水仙花数 Next I Close #1End SubPrivate Sub Form_Click()Text1.Font = 隶书End SubPrivate Sub Command1_Click() Dim s As String Dim i, n As Integer s = n = Len(Text1.Text)*found* 请不要删除该行 For i = 1 To n Step 2 s = s & Mid(Text

8、1.Text, i, 1) Next i*found* 请不要删除该行 Text2.Text = sEnd SubPrivate Sub Command1_Click() Dim i, n As Integer, s As String s = n = 0*found* 请不要删除该行,只在下一行中填空 If Option1.Value = True Then n = 1 s = Option1.Caption ElseIf Option2.Value = True Then n = 10 s = Option2.Caption ElseIf Option3.Value = True Then

9、 n = 15 s = Option3.Caption End If*found* 请不要删除该行,只在下一行中填空 Text1.Text = 乘 & s & 需要 & n & 小时End SubPrivate Sub C1_Click() Dim i, s As Double *begin* For i = 1 To 10 s = s + 1 / (i * i) Next i *end* Print s=; Print Format(s, #.0000); DataWrite (s)End SubSub DataWrite(x As Double) Open App.Path & & pro

10、gout.dat For Output As #1 Print #1, s=; Print #1, Format(x, #.0000) Close #1End SubOption Base 1Private Sub Form_Click() Const M = 5 Dim Mat(M, M) Dim Sum%, i%, j% For i = 1 To M For j = 1 To M Mat(i, j) = i * j Next j Next i Print Print 初始矩阵为: Print For i = 1 To M For j = 1 To M*found* 请不要删除该行 Prin

11、t Tab(5 * j); Mat(i, j); Next j Print Next i Sum = 0 For j = 1 To M*found* 请不要删除该行 Sum = Sum + Mat(3, j) Next j Print Print 第三行各元素的和为:; Print SumEnd SubPrivate Sub Form_Click() Dim a(9) As Integer, x As Integer, k As Integer, I As Integer RandomizeDo While I = 9 x = Int(Rnd * 900 + 100) *found* 请不要删

12、除该行,只在下一行中填空 k = x Mod 10 If a(k) = 0 Then a(k) = x *found* 请不要删除该行,只在下一行中填空 I = I + 1 End IfLoopFor Each y In a Print yNextEnd SubSub SaveData() Dim m As Integer, n As Integer Open App.Path & progin.dat For Input As #1 Open App.Path & progout.dat For Output As #2 For i = 1 To 5 Input #1, m, n Print

13、 #2, s=; Fun(m, n) Next i Close #1 Close #2End SubFunction Fun(m As Integer, n As Integer)*begin*If m Mod 2 0 Then m = m + 1For i = m To n Step 2Fun = Fun + i * iNext i*end*End FunctionPrivate Sub Command1_Click() d = Fun(Val(Text1.Text), Val(Text2.Text) Text3.Text = d If d Empty Then SaveDataEnd Su

14、bPrivate Sub Command1_Click() Dim S As Double Dim Sum As Double Dim I As Integer, J As Integer Sum = 0 For I = 1 To 20*found* 请不要删除该行 S = 1*found* 请不要删除该行 For J = 1 To I S = S * J Next J Sum = Sum + S Next I Text1.Text = Str(Sum)End SubPrivate Sub Command2_Click() EndEnd SubPrivate Sub Form_Load() T

15、ext1.Text = End SubPrivate Sub Command1_Click() Text1.Text = 我的爱好是: If Check1.Value = 1 Then Text1.Text = Text1.Text & Check1.Caption & , End If If Check2.Value = 1 Then*found* 请不要删除该行,只在下一行中填空 Text1.Text = Text1.Text & Check1.Caption & , End If If Check3.Value = 1 Then Text1.Text = Text1.Text & Che

16、ck3.Caption & , End If If Check4.Value = 1 Then Text1.Text = Text1.Text & Check4.Caption*found* 请不要删除该行,只在下一行中填空 End IfEnd SubDim A(10) As IntegerSub SaveData() Dim A(10) As Integer, n As Integer Open App.Path & & PROGIN.DAT For Input As #1 Open App.Path & & PROGOUT.DAT For Output As #2 For I = 1 To

17、 2 For j = 1 To 10 Input #1, A(j) Next j Input #1, n Print #2, n & 的位置为: & Fun(A, n) Next I Close #1 Close #2End SubFunction Fun (A() As Integer, n As Integer) Fun = 0*begin* For I = 1 To 10 If A (I) = n Then Fun = I Exit For End If Next IPrivate Sub Command1_Click() Dim s As String Dim i, n As Inte

18、ger*found* 请不要删除该行 s = Text1.Text n = Len(s) For i = 1 To n*found* 请不要删除该行 s = s & Mid(s, n - i + 1, 1) Next iText2.Text = sEnd SubPrivate Sub Form_Load() HScroll1.Width = Picture1.ScaleWidth HScroll1.Min = 0 HScroll1.Max = HScroll1.Width / 25End SubPrivate Sub HScroll1_Change() Static a As Integer

19、If a HScroll1.Value Then 单击了向左滚动箭头 *found* 请不要删除该行 Shape1.Left = Shape1.Left - 20 ElseIf a HScroll1.Value Then 单击了向右滚动箭头 *found* 请不要删除该行 Shape1.Left = Shape1.Left + 20 End If a = HScroll1.Value 记下当前滚动条位置End SubOption Base 1Dim X() As Integer, N As IntegerSub SaveData() Dim a(20, 20) As Integer, s As

20、 Integer Open App.Path & & PROGIN.DAT For Input As #1 Open App.Path & & PROGOUT.DAT For Output As #2 For j = 1 To 4 For k = 1 To 4 Input #1, a(j, k) Next k Next j Call Fun(a, 4, s) Print #2, The Result is: & s Close #1 Close #2End SubSub Fun(X() As Integer, N As Integer, s As Integer)*begin* For i =

21、 1 To N For j = 1 To N If i + j = N + 1 Then s = s + X(i, j) Next j Next i*end*End SubPrivate Sub Command1_Click() N = Val(InputBox(请输入矩阵的行数N, 数据输入, 5) ReDim X(N, N) Form1.Cls Randomize For i = 1 To N For j = 1 To N X(i, j) = Int(Rnd * 91) + 10 Print X(i, j); Next j Print Next iEnd SubPrivate Sub Co

22、mmand2_Click() Dim s As Integer Call Fun(X, N, s) Print 副对角线元素之和为: & s SaveDataEnd Sub*end*End FunctionPrivate Sub Command1_Click() Dim I As Integer, location As Integer Text1.Text = For I = 1 To 10 A(I) = Int(Rnd * 31) + 20 Text1.Text = Text1.Text & A(I) & Next IEnd SubPrivate Sub Command2_Click() location = Fun(A, Val(Text2.Text) If location = 0 Then Text3.Text = 找不到 & Text2.Text Else Text3.Text = Text2.Text & 是数组中的第 & location & 个元素 End If SaveDataEnd Sub

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

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