VB6 ActiveX ctrl互操作:"AxMSComm"和"MSComm用于串行通信 [英] VB6 ActiveX ctrl Interop: 'AxMSComm' and 'MSComm for serial communication

查看:251
本文介绍了VB6 ActiveX ctrl互操作:"AxMSComm"和"MSComm用于串行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在从vb6移植程序,它使用旧的MSComm类进行一些串行通信.如您所知,升级ActiveX控件时,在类名中添加了前缀"Ax-".现在在主菜单中. Designer.vb的串行comm控件的定义变为:

Hi guys
I''m porting a program from vb6 and it used the old MSComm class to do some serial communication. As some of you know, when ActiveX controls are upgraded there''s a prefix "Ax-" added to the class name. So now in the Main Menu. Designer.vb the definition for the serial comm control becomes:

Public WithEvents MSComm1 As AxMSCommLib.AxMSComm



稍后我在行上遇到一些错误(HRESULT异常:0x800A017C(CTL_E_INVALIDPROPERTYVALUE))



later I''m having some errors (Exception from HRESULT: 0x800A017C (CTL_E_INVALIDPROPERTYVALUE)) on the line

frmMainMenu.MSComm1.Output = Chr(FrameSize)



我认为等式右侧的类型存在问题.但这不是我现在最大的担忧.
我只是想知道,是否可以用在VB08的对象浏览器中看到的MSComm替换此互操作的AxMSComm?那会摆脱整个互操作协议吗?

我想我的最后一招是使用System.IO.Ports.SerialPort进行串行通信,这是.net方式,这意味着我需要摆脱Interop并进行大量重写..
任何想法表示赞赏
--------------
好的..我想在找到一种方法来解决互操作性和使用IO.Ports.Serialport重写代码之间,我必须选择



which I believe there''s something wrong with the type of the right side of the equation. but that''s not my biggest concern now.
I''m just wondering, can I replace this interop AxMSComm with the MSComm which I saw in the Object Browser in VB08? Will that get rid of the whole interop deal?

I guess my last resort is to use System.IO.Ports.SerialPort to do the serial communication, which is the .net way, which means I need to get rid of the Interop and a lot of rewrites..
Any ideas appreciated
--------------
ok.. I think between figuring out a way to wrestle with the interop and rewriting the code using IO.Ports.Serialport , i''d have to choose

推荐答案

我想我的最后一招是使用System.IO.Ports.SerialPort进行串行通信,这是.net方式,这意味着我需要摆脱Interop和大量重写. i>

那就是答案.不要依赖旧的VB6做事方式.最终,VB6运行时支持将死于可悲的死亡.


但是,您无法发送Chr字符.您必须先将其转换为字符串,然后才能将其发送到输出.
I guess my last resort is to use System.IO.Ports.SerialPort to do the serial communication, which is the .net way, which means I need to get rid of the Interop and a lot of rewrites..

That''s the answer. Don''t depend on the old VB6 ways of doing things. Eventually, VB6 runtime support is going to die a justifiably horrible death.


But, you can''t send a Chr character. You have to convert it to a String before you can send it to Output.


这篇关于VB6 ActiveX ctrl互操作:"AxMSComm"和"MSComm用于串行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆