【vb精品源码栏目提醒】:网学会员鉴于大家对vb精品源码十分关注,论文会员在此为大家搜集整理了“VB程序改错40题 - 教育”一文,供大家参考学习
第 2 题 (1.0 分) 题号:129------------------------------------------------【程序改错】------------------------------------------------题目:该程序实现将输入的 0 - 255 之间的正整数转 换成二进制数------------------------------------------------Option ExplicitPrivate Sub Form_Click Const n 8 Dim an As Integer s As String m As Integer x As Integer x ValInputBoxquot请输入一个 0 - 255 之间的正整数:quot Print xFOUND For m 1 To n am x Mod 2FOUND x x / 2 Next m s quot quot For m n To 0 Step -1FOUND s Stram Next m Print s End Sub答案:答案 1For m 0 To n答案 2x x 2或x intx/2答案 3s s Stram第 3 题 (1.0 分) 题号:463------------------------------------------------【程序改错】------------------------------------------------题目:以下程序功能是输入三个数,由大到小排序。
------------------------------------------------Option ExplicitDim A As IntegerDim B As IntegerDim C As IntegerPrivate Sub Form_Click Dim nTemp As Integer A ValInputBoxquotPlease input first integerquot quot输入正整数quot B ValInputBoxquotPlease input second integerquot quot输入正整数quot C ValInputBoxquotPlease input third integerquot quot输入正整数quot FOUND If A lt C Then nTemp A A B B nTemp End If FOUND If B lt C Then nTemp A A C C nTemp End If FOUND If A lt B Then nTemp B B C C nTemp End If Print quotThe integers in order isquot A B CEnd Sub答案:答案 1If A lt B Then或If B gt A Then答案 2If A lt C Then或If C gt A Then答案 3If B lt C Then或If C gt B Then第 4 题 (1.0 分) 题号:127------------------------------------------------【程序改错】------------------------------------------------题目:下面程序可输出如下图形: ------------------------------------------------Option ExplicitPrivate Sub Form_ClickDim m As Integer n As Integer s As String i As Integer j As Integern 4m 1s quotquotFor i 5 To 1 Step -1 FOUND Print Spcn For j 1 To 2 m - 1 Print s Next j Print FOUND n n 1 FOUND m m - 1Next iEnd Sub答案:答案 1Print Spcn或Print Spci或 Spcn或 Spci答案 2n n - 1或n - 1n答案 3m m 1第 5 题 (1.0 分) 题号:469------------------------------------------------【程序改错】------------------------------------------------题目:已知一个函数 fx1000sinx,利用绘图方法 在图片框中显示其图形。
结果如图 1------------------------------------------------Option ExplicitPrivate Const pi 3.14159Private Sub Command1_Click FOUND Dim x As Integer Picture1.Scale -pi -1200-pi 1200 FOUND For x -pi To pi Step pi FOUND Picture1.PSet x 1000 pi Sinx vbRed Next xEnd Sub答案:答案 1Dim x As Single或Dim x答案 2For x -pi To pi Step pi / 180答案 3Picture1.PSet x 1000 Sinx vbRed或Picture1.PSet x Sinx1000 vbRed第 6 题 (1.0 分) 题号:497------------------------------------------------【程序改错】------------------------------------------------题目:编程求一个十进制整数 n 的各位数字之和,设 n 为小于或等于 5 位的数。
------------------------------------------------Option ExplicitPrivate Sub Form_Click Dim N As Integer Sum As Integer S1 As String S2 As String Dim i As Integer Ch As String Sum 0 N InputBoxquot输入整数 nquot S1 StrN FOUND S1 RTrimS1 For i 1 To LenS1 FOUND Ch MidN i 1 FOUND Sum ValCh Next i Print quot该整数的各位数之
上一篇:
2012年9月份考试可视化程序设计(VB)第三次作业.doc
下一篇:
韩国婚纱照片模板下载