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

樓主

Yu Shu
門外漢
0 1
22 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感謝幫助你的人 新手會員瞧一瞧
1樓
回應

林佳正
檢舉此回應
樓上大大
您是想把vb程式碼轉成c語言嗎?
那應該把問題丟到c語言比較對
會c語言的不見得會來看vb區域
而且不同語言雖然很多相似之處
也有很多功能不同
要改寫相當於兩個程式語言都要懂
建議您專一程式比較好
本篇文章回覆於2018-05-23 21:38
== 簽名檔 ==
--未登入的會員無法查看對方簽名檔--
   
1

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