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

admin2009-02-25  45

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

选项

答案控件在运行时是否可用由Enabled属性设置。当Enabled为True时,控件在运行时可用,当Enable为False时,控件在运行时不可用(灰色);单击命令按钮触发其Click事件,其标题由Caption属性设置;Str$函数将数字转换为字符串。 解题步骤: 第一步:建立界面并设置控件属性。程序中用到的控件及其属性见表9-3。 [*] 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 = 1 To N Sum = Sum + Item(A, J) Next J 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) p$ = p$ + Q$ Next i ’? = Val(P$) ’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 = 1 To N Sum = Sum + Item(A, J) Next J Print "Sum="; Sum Open App. Path & "\" & "sjt5.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) P$ = P$ + Q$ Next i S = Val (P$) H = H + S Item = H End Function 第三步:按题目要求存盘。

解析
转载请注明原文地址:https://jikaoti.com/ti/1Oq0FFFM
0

最新回复(0)