代码不执行小弟遇到一个问题,调用外部非托管的dll,SDK中只有VB语言的例子。VB代码如下Private Sub commandg
代码不执行 小弟遇到一个问题,调用外部非托管的dll,SDK中只有VB语言的例子。 VB代码如下
Private Sub commandgetitemname_Click( ) Dim itemNo As Integer itemNo = ReadItemNo() ‘获得项目总数 Dim result As Integer Dim re As Integer Dim i As Integer Dim regname As String * 255 For i = 0 To itemNo - 1 Step 1 ‘读取各个项目名称,并添加到项目列表框中 result = GetItemNames(regname, i) If result <> 0 Then MsgBox (result) Return End If List1.AddItem (regname) Next i
public static extern int GetItemNames(out string sName, ushort wItemId); List<string> lstNames = new List<string>(); for (int i = 1; i < ReadItemNo(); i++) { string itemsNames; GetItemNamesData(out itemsNames, (ushort)i);
If I look at s_ReturnValue in the previous line, it shows "192
with no trailing double quote, which I imaging would be 250 or so places to the right
I get system exception "input string was not in a correct format"
Anyone been here?
Thank you for any ideas.
Greg
ReplyQuote Answers Friday, August 25, 2006 1:55 PM
0Sign In to Vote Try defining s_ReturnValue as System.Text.StringBuilder(255) instead of using the VB6 library data type. [其他解释] 试试将第一个类型改为c#中的System.Text.StringBuilder(255) 类型试试