vb部分考试试题及答案.doc
《vb部分考试试题及答案.doc》由会员分享,可在线阅读,更多相关《vb部分考试试题及答案.doc(18页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1. 图5Private Sub Command1_Click()考生应完成的程序* Begin *Open “in5.dat” for input as #1 Input #1, sClose #1Text1.text=sEnd Subprivate Sub Command2_Click()考生应完成的程序Stetemp2=”For i=1 to len(s) Ch=mid(s,i,1) If i mod 2 0 then If isletter(cstr(ch)=true then If ch=”Z” then Ch=”A” Elseif ch=”z” then Ch=”a” Else C
2、h=chr(asc(ch)+1) End if End if Else If isletter(cstr(ch)=true then If ch=”A” then Ch=”Z” Elseif ch=”a” then Ch=”z” Else Ch=chr(asc(ch)-1) End if End if End if Strtemp2=strtemp2+ch Next i Text2.text=strtemp2* End *End SubFunction isletter(a As String) As Boolean If A = a And a = Z Or a = a And a = z
3、Then isletter = True Else isletter = False End IfEnd FunctionPrivate Sub Command3_Click() Open out5.dat For Output As #1 Print #1, Text2.Text Close #1End Sub 2. (a) (b) Private Sub Command1_Click() If Option1.Value = True And Text1.Text Then List1.AddItem Text1.Text Text1.Text = ElseIf Option2.Value
4、 = True And List1.ListIndex = 0 Then List1.RemoveItem List1.ListIndex Else MsgBox 未输入或未选定项目 End If End IfEnd Sub3. (a)(b)Private Sub Command1_Click() 需考生编写程序 * Begin *Dim s As String Open in5.txt For Input As 1 Line Input #1, s Close #1 Text1.Text = s* End *End SubPrivate Sub Command2_Click() Dim ol
5、dSen As String Dim newSen As String Dim ch As String Dim lastCh As String oldSen = Text1.Text strlen = Len(oldSen) lastCh = Left(oldSen, 1) For i = 1 To strlen ch =Mid(oldSen, i, 1) If lastCh = Then ch = UCase(ch) End If newSen =newSen = newSen & ch lastCh = ch Next i Text1.Text = newSenEnd SubPriva
6、te Sub Command3_Click() Open out5.txt For Output As #1 Write #1, ? Close #1End Sub4. =考生应完成的程序(开始)= *begin* Dim s As Recordtype Open in5.dat For Random As #1 Len = Len(s) maxval = 0 minval = 300 For k = 1 To 20 Get #1, , s sumval = s.a1 + s.a2 + s.a3 If sumval maxval Then maxval = sumval If sumval a
7、(j) Then t = a(i) a(i) = a(j) a(j) = t End If Next jNext i*end*=考生编写程序结束= For i = 1 To 10 s = s & Str(a(i) Next i Label4.Caption = s SaveEnd Sub 6. Open in5.dat For Input As #1 For i = 1 To 100 Input #1, a(i) Next i Close #1End SubPrivate Sub Command2_Click()考生完成* Begin *Sum=0For i=1 to 100 Sum=sum+
8、a(i)Next iSum=int(sum / 100)Min=1000Temp=0For i=1 to 100 If abs(sum-a(i)= 0.0001 Text1.Text = Result * 4End Sub8Private Sub C1_Click() For i =0 To 2 If Op1(i). Value = True Then Print 我的出生地是 + Op1(i). Caption End If NextEnd Sub9. 程序代码Private Sub Form_Unload(Cancel As Integer) Open out4.txt For Outpu
9、t As #1 Print #1, Cb1.Text, Cb2.Text, CInt(L1.Font.Size), L1.Font Close #1End SubPrivate Sub Cb1_Click() L1.FontSize = Cb1.TextEnd SubPrivate Sub Cb2_Click() L1.Font = Cb2.TextEnd Sub10. Private Sub Form_Unload(Cancel As Integer) unload_subEnd SubPrivate Sub Command1_Click() If Op1.Value ThenText1.F
10、ontName = Op1.Caption ElseIf Op2.Value ThenText1.FontName = Op2.Caption End IfIf Ch1.Value = 1 ThenText1.FontUnderline = True ElseText1.FontUnderline = FalseEnd If If Ch2.Value = 1 ThenText1.FontItalic = TrueElse Text1.FontItalic = FalseEnd IfEnd Sub11 属性设置Private Sub Command1_Click() Dim n As Long
11、CD1.FileName = CD1. Filter = 所有文件|*.*|文本文件|*.txt|Word文档|*.doc CD1.FilterIndex = 2 CD1. Action = 1 If CD1.FileName Then Open CD1.FileName For Input As #1 n = LOF(1) Text1 = Input$(n, #1) Close #1 End IfEnd Sub12Private Sub Command1_Click() Dim k As Integer, s As Single, a As Single, b As Single a = V
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- vb 部分 考试 试题 答案
限制150内