我照着这个程序做了个小闹钟,但是运行的时候,指出
     
    Sub deng()
      Dim ss
       ss = Shell(Label1.Caption, 1)
      End
     '启动指定的文件,并且结束小闹钟程序
     End Sub 这是"无效的过程调用或参数"  ???
以下是原程序:  Option Explicit
     Dim AlarmTime     Private Sub Command1_Click()
      Call dialog
     '调用dialog子程序
     End Sub
     Private Sub Command2_Click()
      AlarmTime = InputBox("请输入你想设定的时间,例如(20:30:00)", "小闹钟")
      If AlarmTime = "" Then Exit Sub
      If Not IsDate(AlarmTime) Then
      MsgBox "你所输入发不是时间格式,请重试!", , "Wrong"
      Else
      AlarmTime = CDate(AlarmTime)
      End If
    End Sub     Private Sub Command3_Click()
      Call deng
     '调用deng子程序
     End Sub
  
Private Sub Command4_Click()
 End
End Sub     Private Sub Form_Click()
      frmAbout.Show
     '显示关于对话框
     End Sub
 
     Private Sub Form_Load()
      Command3.Enabled = 0
      AlarmTime = ""
     '初始化时command3为不可用的
     End Sub
 
     Private Sub Form_Resize()
      If WindowState = 1 Then
      Call mintime
       Else
       Caption = "小闹钟"
      End If
     '如果窗口被最小化,则调用mintime程序
     End Sub     Private Sub mintime()
       Caption = Format(Time, "Long Time")
     '使用长时间格式来显示时间
     End Sub     Private Sub Timer1_Timer()
      If Label2.Caption <> CStr(Time) Then
       Label2.Caption = AlarmTime
       Label4.Caption = Time
      End If
     '显示时间每秒钟的变化
      If Time >= AlarmTime Then
       Call deng
      End If
     '判断如果现在的时间超过了设定的时间,则调用deng子程序
      If WindowState = 1 Then
      If Minute(CDate(Caption)) <> Minute(Time) Then
       mintime
      End If
      End If
     '最小化时显示时间每分钟的变化
     End Sub
  
     Sub dialog()
      CommonDialog1.Flags = cdlCFBoth
      CommonDialog1.ShowOpen
      Label1.Caption = CommonDialog1.FileName
      If Label1 <> "" Then
       Command3.Enabled = -1
      Else
      Exit Sub
      End If
     '把打开的文件名给于label1
     '如果label1不为空时,则command3即可用
     End Sub
     Sub deng()
      Dim ss
       ss = Shell(Label1.Caption, 1)
      End
     '启动指定的文件,并且结束小闹钟程序
     End Sub

解决方案 »

  1.   

    我试了 可以用的 
    你看看出错时Label1.Caption的值是多少
      

  2.   

    其 label caption 为空值
      

  3.   

    Sub dialog()
          CommonDialog1.Flags = cdlCFBoth
          CommonDialog1.ShowOpen '你选择了什么程序了吗?要选择一个可运行的程序      Label1.Caption = CommonDialog1.FileName
          If Label1 <> "" Then '有错!!!
           Command3.Enabled = -1
          Else
          Exit Sub
          End If
      

  4.   

    推荐使用 ShellExecute () API 执行其他程序,方便很多。
      

  5.   

    Sub dialog()
          CommonDialog1.Flags = cdlCFBoth
          CommonDialog1.ShowOpen '你选择了什么程序了吗?要选择一个可运行的程序
            (在运行的时候自主选择的,选择后,程序会出现在 Label1.Caption里)      Label1.Caption = CommonDialog1.FileName'把打开的文件名给于label1
          If Label1 <> "" Then '有错!!!(???还是不搞不清楚错在哪里?)
           Command3.Enabled = -1
          Else
          Exit Sub
          End If
      

  6.   

    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    ''  fileFullPath
        Dim j As Long
      '执行外部程序,  ExtractFilePath() 自定义函数:取得文件全路径中的路径。
      j = ShellExecute(0, "open", fileFullPath, "", ExtractFilePath(fileFullPath), 1)
      If j = 42 Then
        '执行成功
      else
        '执行失败。FormatMessage() API 可以得到错误信息。
      end if
      

  7.   

    你点完command1选好可执行文件后,该文件的路径就会保存在lable1里面,label1的值怎么会为空呢