查看完整版本: 沒有設定物件變數或 With 區塊變數
頁: [1]

falsesmile777 發表於 2022-5-24 04:30 AM

沒有設定物件變數或 With 區塊變數

'*****************************************************
'*   PLX-DAQ Data Acquisition for Excel "Version 2"  *
'*   now running with Office 32 and 64 bit           *
'*                                                   *
'* Based on the PLX-DAQ from Martin Hebel            *
'* optimized for 64 bit by Jonathan Arndt            *
'* using the COMM port API module from David Hitchner*
'*                                                   *
'* BIG THANKS TO BOTH OF YOU FOR GREAT CODE !! :-)   *
'*                                                   *
'*****************************************************
'*   Programmed by:  Jonathan Arndt   November, 2016 *
'*                   arndt.jonathan@googlemail.com   *
'*****************************************************
'* --------------------------------------------------*
'* "THE BEER-WARE LICENSE" (Revision 42):            *
'* Net^Devil wrote this file. As long as you retain  *
'* this notice you can do whatever you want with     *
'* this stuff. If we meet some day, and you think    *
'* this stuff is worth it, you can buy me a beer     *
'* in return -- Jonathan Arndt, Stuttgart, Germany   *
'* --------------------------------------------------*
'*****************************************************
'*   Original remark from Martin Hebel:              *
'*                                                   *
'*   PLX-DAQ Data Acquisition for Excel              *
'*   Copyright 2007, Parallax Inc.                   *
'*   PLX-DAQ is a trademark of Parallax, Inc.        *
'*   www.parallax.com                                *
'*   Programmed by:  Martin Hebel   January, 2007    *
'*                   martin@selmaware.com            *
'*   Modified distribution of this macro is          *
'*   not permitted.  Use of the SelmaDAQ Active-X    *
'*   control for other uses requires permission of   *
'*   SelmaWare Solutions -    www.selmaware.com      *
'*****************************************************

Dim row As Long
Dim FlagConnect As Boolean
Dim TimeStart
Dim TimeLast
Dim TimeAdd
Dim cc
Dim WStoUse As Worksheet


Private Const SettingsSheet = "PLXDAQ_new_Settings"
Private Const colSettings = "C"
Private Const rowCurPort = 3
Private Const rowCurBaud = 4
Private Const rowCurRstOnCnt = 5
Private Const rowCurDwnlData = 6
Private Const rowCurClrStdData = 7
Private Const rowCurUser1 = 8
Private Const rowCurUser2 = 9
Private Const rowCur1WS = 10
Private Const rowCurActWS = 11

Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 64 Bit Systems

Private Sub cboBAUD_Change()
   
    '## Baud rate change - if already running close connection and reopen
    If (FlagConnect) Then
        Call CommClose(cboPort.Text)
        Call CommOpen(cboPort.Text, "COM" & CStr(cboPort.Text), "baud=" & cboBAUD.Text & " parity=N data=8 stop=1")
    End If
        
    ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurBaud, colSettings) = cboBAUD.Text
   
End Sub

Private Sub cboPort_Change()

    '## Port change - if already running close connection (using old port !! ) and reopen
    If (FlagConnect) Then
        Call CommClose(ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurPort, colSettings))
        Call CommOpen(cboPort.Text, "COM" & CStr(cboPort.Text), "baud=" & cboBAUD.Text & " parity=N data=8 stop=1")
    End If
   
    ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurPort, colSettings) = cboPort.Text
   
End Sub

Private Sub chkDTR_Click()
    ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurRstOnCnt, colSettings) = chkDTR.Value
End Sub

Private Sub chkReset_Click()
    ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurClrStdData, colSettings) = chkReset.Value
End Sub

Private Sub ChkUser1_Click()
   ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurUser1, colSettings) = ChkUser1.Value
End Sub

Private Sub ChkUser2_Click()
   ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurUser2, colSettings) = ChkUser2.Value
End Sub

Private Sub chkDump_Click()
    ThisWorkbook.Sheets(SettingsSheet).Cells(rowCurDwnlData, colSettings) = chkDump.Value
End Sub

Private Sub cmdDebugWindow_Click()
   
    If (cmdDebugWindow.Caption = "Display direct debug =>...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>
頁: [1]