beautypg.com

GW Instek GSP-827 Programming Manual User Manual

Page 16

background image

Copyright 2003 GOODWILL INSTRUMENT CO., LTD.

Dim STime As Double, NTime As Double, Wait As Double

STime = timeGetTime

NTime = timeGetTime

Wait = NTime - STime

Do Until Wait >= DelaymSec

DoEvents

NTime = timeGetTime

If NTime < STime Then

'Maximum timegettime 2^32

Wait = 2 ^ 32 - STime + NTime

Else

Wait = NTime - STime

End If

Loop

End Function

'============================ Send command to GSP-827 ====================================

Public Function SendCMD(CMD As String) As Boolean

Dim Q As String

If Not MSComm1.PortOpen Then

'If port is not open, quit and return false

SendCMD = False

Exit Function

End If

MSComm1.Output = Trim(CMD) & Chr(13)

'Add CR at end of command and send the command to unit

Q = ReadCOM()

'Read the return from unit

Q = Trim(Replace(Q, Chr(13), " ", 1))

'Replace CR with space

If Q = "OK" Then

ErrStr = ""

SendCMD = True

Else

ErrStr = Trim(rdBuffer)

SendCMD = False

End If

End Function

'========================== Send query command and read the return string ====================================

Public Function SendQuery(QueryStr As String) As String

Dim Q As String

If Not MSComm1.PortOpen Then Exit Function

If MSComm1.InBufferCount Then

'Delete the data in buffer

rdBuffer = MSComm1.Input