【vb精品源码栏目提醒】:网学会员鉴于大家对vb精品源码十分关注,论文会员在此为大家搜集整理了“vb历届考试答案 - 计算机等级”一文,供大家参考学习
第十九次等级考试 2003 年 10 月 19 日 二级《Visual Basic》上机考试试卷《第一套》一、调试程序:(程序存盘文件名 TEST11.FRM、TEST11.VBP)Private Sub Command1_Click Dim n As String Dim k As Integer Dim i As Integer Dim j As Integer Cls 添加 Do n InputBoxquot请输入一个大写英文字母:quot Loop Until Lenn 1 And n gt quotAquot And n lt quotZquot 修改 k 0 修改 For i 1 To 6 Print Tab25 For j 1 To 6 k k 1 If Ascn k - 1 gt AscquotZquot Then k k - 26 添加 Print ChrAscn k - 1 Space1 修改 Next j 修改 Print Next iEnd Sub二、编制程序:(程序存盘文件名 Test12.vbp)(60 分)Private Sub Command1_Click Dim i List2.Clear For i 0 To 29 n ValList1.Listi If n Mod 4 0 And n Mod 100 ltgt 0 Or n Mod 400 0 Then List2.AddItem n NextEnd SubPrivate Sub Command2_Click Dim i k t For i 0 To List2.ListCount - 2 k i For j i 1 To List2.ListCount - 1 If ValList2.Listk gt ValList2.Listj Then k j Next If k ltgt i Then t List2.Listk List2.Listk List2.Listi List2.Listi t End If NextEnd SubPrivate Sub Form_Load Dim i Randomize For i 1 To 30 List1.AddItem IntRnd 3901 100 NextEnd Sub 第十九次等级考试 2003 年 10 月 19 日 二级《Visual Basic》上机考试试卷《第二套》一、调试程序(程序存盘文件名为 TEST21.vbp,TEST21.frm)40 分Private Sub Command1_ClickDim ObjectString As StringDim ResultString As StringDim objLength As IntegerDim delLength As IntegerDim temp As StringDim i As IntegerDim DelString As String 添加ObjectString Text1.TextDelString Text2.TextobjLength LenObjectStringdelLength LenDelStringi 1Do While i lt objLength 修改 temp MidObjectString i delLength If temp ltgt DelString Then ResultString ResultString MidObjectString i 1 i i 1 Else i i delLength 修改 End If 修改Loop Text3.Text ResultStringEnd SubPrivate Sub Form_Load Command1.Caption quot删除quot 添加End Sub二、编制程序:(程序存盘文件名 TEST22.vbp、TEST22.Frm)(60 分)Private Sub Command1_Click Dim a Open quotd:testtest22in.txtquot For Input As 1 Input 1 a Text1 a CloseEnd SubPrivate Sub Command2_Click Dim a a 应为变体类型 Dim i j a SplitText1 quot quot 分解字符串 For i LBounda To UBounda ai Trimai 删除每个字符串前后的空格 Next 冒泡排序 For i LBounda To UBounda - 1 For j LBounda To UBounda - i - 1 If aj lt aj 1 Then t aj aj aj 1 aj 1 t End If Next Next Text2 aLBounda For i LBounda 1 To UBounda Text2 Text2 amp quot quot amp ai NextEnd SubPrivate Sub Command3_Click Open quotd:testtest22in.txtquot For Append As 1 Print 1 Text2 Close MsgBox quot数据已追加到文件中quotEnd SubPrivate Sub Form_Load Text1 quotquot Text2 quotquotEnd Sub 第十九次等级考试 2003 年 10 月 19 日 二级《Visual Basic》上机考试试卷《第三套》一、调试程序(程序存盘文件名为 TEST31.vbp,TEST31.frm)40 分Private Sub Form_Load List1.Clear List2.Clear Command1.Enabled True Command2.Enabled FalseEnd SubPrivate Sub Command1_Click Dim a As Integer Open quottest31in.txtquot For Input As 1 Do While Not EOF1 Input 1 a List1.AddItem a Loop Close 1 Command1.Enabled False Command2.Enabled TrueEnd SubPrivate Sub Command2_Click Dim n As Integer Dim strBinary As String Dim i As Integer Dim j As Integer For i 0 To List1.ListCount - 1 n List1.Listi strBinary qu