本文介绍了您好需要帮助在vb和c#:)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用DLL和教程如何在VB中使用某些函数。 问题是我不熟悉VB,我需要在C#中实现$ 这是VB中的教程I'm using a DLL and a tutorial how to use some function in VB.The problem is I'm not familiar with VB and I need to implement in C#This is the tutorial in VBPrivate Declare Function InitComm Lib "pf500.dll" (ByVal portnum As Byte) As LongPrivate Declare Function SendCommand Lib "pf500.dll" Alias "WriteCommand" (ByVal porthnd As Long, ByVal seq As Byte, ByVal vlez As String, ByVal izlez As Long, ByVal stats As Long) As IntegerPublic Function WriteCommand(ByVal com_port As Byte, ByVal seq As Byte, ByVal sVlez As String, ByRef sIzlez As String, ByRef sStatus As String) As Integer sIzlez = String$(256, vbNullChar) sStatus = String$(256, vbNullChar) Dim lngPortHandle As Long Dim lngIzlez As Long Dim lngStatus As Long lngIzlez = StrPtr(sIzlez) lngStatus = StrPtr(sStatus) If ((seq < 32) Or (seq > 127)) Then sIzlez = "Sekventniot broj MORA da pripagja vo intervalot od [32,127]" sStatus = "GRESEN Sekventen broj" Exit Function End If If (Len(sVlez) = 0) Then sIzlez = "Parametarot vlez e cmd+data, znaci -mora- da bide min. 1 znak dolg" sStatus = "GRESNA vrednost za parametarot vlez" Exit Function End If lngPortHandle = InitComm(com_port) If lngPortHandle > 0 Then If (SendCommand(lngPortHandle, seq, sVlez, lngIzlez, lngStatus) >= 0) Then 'prakjanje na komandata sIzlez = AnsiZtoString(lngIzlez) sStatus = AnsiZtoString(lngStatus) Else sIzlez = "Neuspeshno prakjanje/primanje na podatoci od COM" + str(com_port) sStatus = "GRESKA" End If CloseComm (lngPortHandle) Else sIzlez = "Portot COM" + str(com_port) + " ne e pronajden!" sStatus = "GRESKA" End If 这就是我使用InitComm的方式and this is how i use InitComm[DllImport("pf500.dll", CharSet = CharSet.Unicode)] public static extern long InitComm(byte s); 并且运行良好 问题出在send命令??? i没有ideo什么意思是别名writecommandand works goodthe problem is on sendcommand???i have no ideo what means alias writecommand[DllImport("pf500.dll", CharSet = CharSet.Unicode)] public static extern int WriteCommand(long portnum, byte seq, string hyrje, long dalje, long stats); 这是我尝试的方式,但我得到这样的错误 无法找到名为'Send Command的入口点'在DLL中'pf500.dll'。 问题是如何在C#中实现这一个:this is how i try it but i got error like this"Unable to find an entry point named 'Send Command' in DLL 'pf500.dll'."The problem is how to implement in C# this one:Private Declare Function SendCommand Lib "pf500.dll" Alias "WriteCommand" (ByVal porthnd As Long, ByVal seq As Byte, ByVal vlez As String, ByVal izlez As Long, ByVal stats As Long) As Integer 抱歉我的英文不好sorry for my bad english推荐答案 这就是我使用InitComm的方式and this is how i use InitComm[DllImport("pf500.dll", CharSet = CharSet.Unicode)] public static extern long InitComm(byte s); 并且运行良好 问题出在send命令??? i没有ideo什么意思是别名writecommandand works goodthe problem is on sendcommand???i have no ideo what means alias writecommand[DllImport("pf500.dll", CharSet = CharSet.Unicode)] public static extern int WriteCommand(long portnum, byte seq, string hyrje, long dalje, long stats); 这是我尝试的方式,但我得到这样的错误 无法找到名为'Send Command的入口点'在DLL中'pf500.dll'。 问题是如何在C#中实现这一个:this is how i try it but i got error like this"Unable to find an entry point named 'Send Command' in DLL 'pf500.dll'."The problem is how to implement in C# this one:Private Declare Function SendCommand Lib "pf500.dll" Alias "WriteCommand" (ByVal porthnd As Long, ByVal seq As Byte, ByVal vlez As String, ByVal izlez As Long, ByVal stats As Long) As Integer 抱歉我的英文不好sorry for my bad englishPrivate Declare Function SendCommand Lib "pf500.dll" Alias "WriteCommand" (ByVal porthnd As Long, ByVal seq As Byte, ByVal vlez As String, ByVal izlez As Long, ByVal stats As Long) As Integer 使用名称 SendCommand 来引用函数 WriteCommand 。在你的C#声明中,你应该使用 WriteCommand ,它应该可以工作。有关VB声明的完整详细信息,请参阅 http://msdn.microsoft.com /en-us/library/aa243324(v=vs.60).aspx [ ^ ]。is using the name SendCommand to refer to the function WriteCommand in the DLL. In your C# declaration you should just use WriteCommand and it should work. For full details of the VB declaration see http://msdn.microsoft.com/en-us/library/aa243324(v=vs.60).aspx[^]. 这篇关于您好需要帮助在vb和c#:)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-22 17:24