当前位置: 代码迷 >> C# >> mscomm控件,vb6转c#该怎么处理
  详细解决方案

mscomm控件,vb6转c#该怎么处理

热度:76   发布时间:2016-05-05 03:29:31.0
mscomm控件,vb6转c#

On Error Resume Next
            MSComm1.PortOpen = True
            MSComm1.Output = Chr$(27) & Chr$(61) & Chr$(2) 'MSComm1.Output = "**"
            MSComm1.Output = Chr$(12)    '清屏
            MSComm1.Output = "您好,欢迎光临" & Chr$(10) & vbCr
            MSComm1.PortOpen = False
            If Err.Number <> 0 Then
                     n = MsgBox(" 开启出错,请检查端口")
            Err.Clear
            End If


刚接触vb,想问一下第一行以及最后的错误码判断在c#怎么写
------解决思路----------------------
try
{
MSComm1.PortOpen = True
            MSComm1.Output = Chr$(27) & Chr$(61) & Chr$(2) 'MSComm1.Output = "**"
            MSComm1.Output = Chr$(12)    '清屏
            MSComm1.Output = "您好,欢迎光临" & Chr$(10) & vbCr
            MSComm1.PortOpen = False
}
catch(Exception ex)
{
 n = MsgBox(" 开启出错,请检查端口")
}