注意:下面出现的“考生文件夹”均为c:\wexam\25160001。 在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时

admin2009-02-25  29

问题 注意:下面出现的“考生文件夹”均为c:\wexam\25160001。
    在考生文件夹下有工程文件sjt5.vbp及窗体文件sjt5.frm,该程序是不完整的,请在有?号的地方填入正确内容,然后删除?及所有注释符(即’号),但不能修改其他部分。存盘时不得改变文件名和文件夹。
   本题描述如下:在名称为Forml的窗体上有三个Label控件和两个名称分别为COMSTART、 COMEXIT,标题分别为“开始”和“退出”的命令按钮。编写函数Item(A,N),其功能是由数字A组成的不多于N位数的整数,利用该函数求8888-888-88-8的值并把结果写入考生文件夹下的sjt5.dat文件中。执行完毕“确定”按钮,变成“完成”,且无效。如图10-6所示。

选项

答案控件是否可用由其Enable属性设置,当Enable为True时控件可用,当Enable为False时控件不可用(灰色):命令按钮的标题由Caption属性设置:Str$函数将数字转换为字符串。解题步骤: 第一步:建立界面并设置控件属性。程序中用到的控件及其属性值见表10-4。 [*] 程序提供的代码: Option Explicit Private Sub COMEXIT_Click() End End Sub Private Sub COMSTART Click() Dim A As Integer, N As Integer, J As Integer, Sum As Single A= 8: N= 4 For J = N To 1 Step -1 If J = N Then Sum = Item (A, J) Else Sum = Sum - Item(A, J) End If Next Print "Sum="; Sum Open App. Path & "\" & "sjt5.dat" For Output As #1 Print #1, Sum Close #1 ’?.Caption = "完成" ’COMSTART. ? = False End Sub Function Item(A, k) Dim P As String, Q As String, S As Single Dim i As Integer, H As Single p = "" For i = 1 To k Q$ =Str$ (A) pS = pS + Q$ Next i ’? = Val(PS) ’H = ? + S Item = H End Function 参考代码: Option Explicit Private Sub COMEXIT Click() End End Sub Private Sub COMSTART Click() Dim A As Integer, N As Integer, J As Integer, Sum As Single A= 8: N = 4 For J = N To 1 Step -1 If J = N Then Sum = Item(A, J) Else Sum = Sum - Item(A, J) End If Next Print "Sum="; Sum Open App. Path & "\" & "sjtS.dat" For Output As #1 Print #1, Sum Close #1 COMSTART.Caption = "完成" COMSTART.Enabled = False End Sub Function Item(A, k) Dim P As String, Q As String, S As Single Dim i As Integer, H As Single p = "" For i = 1 To k Q$ = Str$ (A) PS = PS + Q$ Next i S = Val (PS) H = H + S Item = H End Function 第二步:调试并运行程序。 第三步:按题目要求存盘。

解析
转载请注明原文地址:https://kaotiyun.com/show/Uh1p777K
0

随机试题
最新回复(0)