台灣最大程式設計社群網站
線上人數
532
 
會員總數:242453
討論主題:187503
歡迎您免費加入會員
討論區列表 >> VB6 >> vb6改寫成c#
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
vb6改寫成c#
價值 : 20 QP  點閱數:126 回應數:0

樓主

Yu Shu
門外漢
0 1
16 0
發送站內信




Public Function MTRSendCommand(c As String, s() As Byte, leng As Long, _
ByRef mtrData() As Byte) As Long ''20080111

Dim calib As Boolean ''20080111
Dim cmd(0 To 3) As Byte ''20070918
Dim cmdData() As Byte ''20080408
Dim i As Long ''20070918
Dim mtrDataResult() As Byte ''20070914
Dim result As Long ''20070918
Dim scmd() As Byte ''20070918

MTRSendCommand = 0 ''20070918
scmd = c ''20070918
cmd(0) = scmd(0) ''20070918
cmd(1) = scmd(2) ''20070918
cmd(2) = scmd(4) ''20070918
cmd(3) = scmd(6) ''20070918

If leng > 0 Then ''20070918
' handle any data with the command
ReDim cmdData(4 + leng - 1) ''20080523
For i = 0 To 3 ''20070918
cmdData(i) = cmd(i) ''20070918
Next i ''20070918
For i = 0 To leng - 1 ''20070921
cmdData(i + 4) = s(i) ''20070918
Next i ''20070918
m_DPOcx.mtrDataSA = cmdData ''20070918
Else ''20070918
' just do the command
m_DPOcx.mtrDataSA = cmd ''20070914
End If ''20070918
m_DPOcx.MTRCommandBinary Nothing ''20070914

calib = False ''20080111
scmd = "CAL" ' CALF or CALR for calibration (word chars) ''20080117
If (cmd(0) = scmd(0)) And (cmd(1) = scmd(2)) And (cmd(2) = scmd(4)) Then ''20080226
calib = True ''20080111
End If ''20080117
scmd = "FRM" ' FRMT for NAND file system ''20080730
If (cmd(0) = scmd(0)) And (cmd(1) = scmd(2)) And (cmd(2) = scmd(4)) Then ''20080226
calib = True ''20080111
End If ''20080117
scmd = "USB" ' USB tests can also take a long time ''20080226
If (cmd(0) = scmd(0)) And (cmd(1) = scmd(2)) And (cmd(2) = scmd(4)) Then ''20080226
calib = True ''20080111
End If ''20080117

TraceIt ("MTRSendCommand // cmnd=" & c) ''20081118
result = MTRWaitForEvent(eMTRResponseBinary, calib) ''20080111
If result <> 0 Then ''20070918
MTRSendCommand = result ''20070918
Exit Function ''20070918
End If ''20070918
' test response
mtrDataResult = m_DPOcx.mtrDataSA ''20070914

If (mtrDataResult(0) = Asc("F") _
And mtrDataResult(1) = Asc("A") _
And mtrDataResult(2) = Asc("I") _
And mtrDataResult(3) = Asc("L")) Then ''20080229
MTRSendCommand = ERROR_MTRRESPONSEBINARY_FAIL ''20070914
' fall through to get any extra error data
ElseIf (mtrDataResult(0) = Asc("O") _
And mtrDataResult(1) = Asc("K") _
And mtrDataResult(2) = Asc("O") _
And mtrDataResult(3) = Asc("K")) Then ''20080229
' success
Else ''20080229
MTRSendCommand = ERROR_MTRRESPONSEBINARY_FAIL ''20070914
Exit Function ''20070914
End If ''20080229

If UBound(mtrDataResult) >= 4 Then ''20080225
For i = 0 To UBound(mtrDataResult) - 4 ''20070918
mtrData(i) = mtrDataResult(i + 4) ''20070918
Next i ''20070918
End If ''20070918
End Function

搜尋相關Tags的文章: [ c# ] , [ vb ] ,
本篇文章發表於2018-05-10 17:57
別忘捐VP感謝幫助你的人 新手會員瞧一瞧
目前尚無任何回覆
   

回覆
如要回應,請先登入.