各位大哥:
现在界面上有两个文本框,一个是计时器(txtCirl),一个是机器名(txtComputer),要求在计时器中输入的时间间隔到了的时候同步输入机器名的机器上的时间。 请各位大哥帮帮忙,怎么写??
我写了下面的代码,没反应
Me.Timer1.Interval = Me.txtCirl.Text
Dim x
x = Shell("cmd.exe /c net time \\ " & Me.txtComputer.Text & txtComputer.TExt/set/y, 1).

解决方案 »

  1.   

    试试:Call Shell("cmd.exe /c ""net time \\localhost""", vbNormalFocus)就是把 net time \\计算机名  前后都加上双引号
      

  2.   

    Shell "command.com /c net time  \\ip地址  /set /yes"
    注意ip地址后跟空格加 /set 再跟空格加/yes
      

  3.   

    不要用cmd,否则win98下是不能用的
      

  4.   

    完整代码:
    Option Explicit
    ' Shows how to shell to another program, and wait until it finishes
    ' before continuing.
    '
    Private Declare Function WaitForSingleObject Lib "kernel32" _
       (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As LongPrivate Declare Function CloseHandle Lib "kernel32" _
       (ByVal hObject As Long) As Long
       
    Private Declare Function OpenProcess Lib "kernel32" _
       (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
        ByVal dwProcessId As Long) As Long
    Private Const INFINITE = -1&
    Private Const SYNCHRONIZE = &H100000Private Sub Command1_Click()
        Dim iTask As Long, ret As Long, pHandle As Long
    Dim strcmd As String
    strcmd = "cmd /c net time \\" + Me.txtComputer.Text + " > " + "nettime.txt"
        iTask = Shell(strcmd, vbHide)
        pHandle = OpenProcess(SYNCHRONIZE, False, iTask)
        ret = WaitForSingleObject(pHandle, INFINITE)
        ret = CloseHandle(pHandle)
        MsgBox "程序运行完成!"
            Dim FileNo As Integer, st As String
            FileNo = FreeFile
     Open App.path + "\nettime.txt" For Input As #FileNo
       Line Input #FileNo, st
        Close
        MsgBox st
    End Sub
    100分给我!!!!!!!!!!!!!!!!!!!!
      

  5.   

    Call Shell("net time \\ " & Me.txtComputer.Text , vbNormalFocus)
    如果在WIN98系统上运行,要把NET.EXE这个工具打包到程序中,执行就要改成:
    Call Shell(app.path & "\net time \\ " & Me.txtComputer.Text , vbNormalFocus)