正在加载图片...
Dim s As long N= Val(Textl. Text J=0 S=0 For i=l to Next i Labell Caption Str(S) End sub 运行该程序,并单击窗体上的命令按钮时,标签中显示的内容为 5.以下程序使用 Mousedow事件检测按下的鼠标按钮(2分)。 Private Sub Form MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If But ton =1 Then print You pressed the left but ton If But ton =2 Then Print You Pressed the right button If But ton 4 Then print You pressed the middle but ton End sub 运行该程序后,当我们在窗体上同时按下鼠标左右两个按钮后,窗体上显示的信 息为: 六、阅读以下各程序,在空格处填上合适的内容,使之完成相应的功能(每空2 分,共24分) 1.用文本框显示按钮单击次数,按钮名称属性为 cmd Count,文本框名称属性为 txtShowCount。布置属性窗口如图1所示,请填空完成代码。 口区 计数 图1 Option Explicit Private Sub Form Load() n Count =0 End sub Sub ()’按钮单击Dim S As Long N = Val(Text1.Text) J = 0 S = 0 For I = 1 To N J = J + I S = S + J Next I Label1.Caption = Str(S) End Sub 运行该程序,并单击窗体上的命令按钮时,标签中显示的内容为_________ 5.以下程序使用 MouseDown 事件检测按下的鼠标按钮(2 分)。 Private Sub Form_MouseDown(Button As Integer, Shift As Integer,X As Single, Y As Single) If Button = 1 Then Print "You Pressed the left button." If Button = 2 Then Print "You Pressed the right button." If Button = 4 Then Print "You Pressed the middle button." End Sub 运行该程序后,当我们在窗体上同时按下鼠标左右两个按钮后,窗体上显示的信 息为:_____________ 六、阅读以下各程序,在空格处填上合适的内容,使之完成相应的功能(每空 2 分,共 24 分) 1.用文本框显示按钮单击次数,按钮名称属性为 cmdCount,文本框名称属性为 txtShowCount。布置属性窗口如图 1 所示,请填空完成代码。 图 1 Option Explicit ______________________ Private Sub Form_Load( ) nCount = 0 End Sub Private Sub_______________( ) '按钮单击
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有