用c#改写一段VB程序

lostowner lostowner 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Private Function OpenCL2018Com(iCom As Integer, sBTl As String) As Boolean
Dim sTmp As String

wskCL2018.Close
wskCL2018.RemoteHost = "193.168.18.1"
wskCL2018.RemotePort = 10003
wskCL2018.Bind 20000 + (iCom - 1) * 2
wskCl2018BTL.Close (wskCl2018BTL是winsock控件)
wskCl2018BTL.RemoteHost = "193.168.18.1"
wskCl2018BTL.RemotePort = 10003
wskCl2018BTL.Bind 20001 + (iCom - 1) * 2

If InStr(sBTl, ",") Then sTmp = "init " & Replace(sBTl, ",", " ")
If InStr(sBTl, "-") Then sTmp = "init " & Replace(sBTl, "-", " ")

“Init 19200 8 1 0 “

Call wskCl2018BTL.SendData(sTmp) (初始化端口波特率)
txtMsg.Text = Time & "-->打开端口COM" & CStr(iCom) & "成功,初始化波特率:" & sBTl & vbCrLf & txtMsg.Text
OpenCL2018Com = True
bOpenCom = True
End Function

说明:
wskCL2018是winsock 采用的是UDP的通讯方式
...全文
评论 13
收藏 已收藏
分享
返回顶部
lostowner
C# 111,129 成员 642,540 内容