在LhServer.dll中函数如下
typedef struct
{
   char* inter_id;
   char* amount;
}Titem;
int __stdcall CheckOut(int lRows, test* Titem)在VB中申明如下
private Type Titem
     inter_id as string  
     amount  as string
END Type
Public Declare Function CheckOut Lib "LhServer.dll" CheckOut(byval lRows as long, test as Titem) as long
 dim t(2) as Ttiem
 dim i as long 
   for i=1 to 2 
      t(i).inter_id ="id" & i
      t(i).amount="mount" & i
   next
  CheckOut(2,titem(0)) 但现在条用后 只有一条值传递成功,后面都没有成功
请教各位那个地方引用不对

解决方案 »

  1.   

    for i=1 to 2 初始化的是 t(1),t(2)
    checkOut(2,titem(0)) 传递的是 t(0),t(1) 吧!
      

  2.   

    dim t(2) as Ttiem '数组的下标是0
    dim i as long
    for i=0 to 1
    .....
      

  3.   

    敲错了哈
    应该是
    typedef struct
    {
       char* inter_id;
       char* amount;
    }Titem;
    int __stdcall CheckOut(int lRows, test* Titem)在VB中申明如下
    private Type Titem
         inter_id as string  
         amount  as string
    END Type
    Public Declare Function CheckOut Lib "LhServer.dll" CheckOut(byval lRows as long, test as Titem) as long
     dim t(2) as Ttiem
     dim i as long 
       for i=0 to 1 
          t(i).inter_id ="id" & i
          t(i).amount="mount" & i
       next
      CheckOut(2,titem(0))
      

  4.   

    你更正了还是出错?你不说谁知道!
    调试一下 CheckOut,既然第一条能进去,应该是内部的问题了。
      

  5.   

    只能第一条进去就对了。你看看CheckOut函数的定义:int __stdcall CheckOut(int lRows, test* Titem)//第二个参数应该是Titem* test吧人家只要一个结构体,你确想给人数组,函数能返回你想要的结果吗?
      

  6.   

    这到不一定,C 中用 Tiitem++ 的方式移动指针的确可以访问数组成员,不过有时后由于内存对齐的问题会出错,本例中应该没有影响。
      

  7.   

    鸟兄说得没错,使用指针可以访问任意类型的数据。但是假如这个函数是你写的话,你会使用这么不安全的方式来访问数组数据吗?从结果看,很显然函数里并没有使用Tiitem++ 这种数据方式。
      

  8.   

    除非性能要求比较变态,我一般不考虑同时用 C 和 VB 两种语言开发,毕竟用 C 去操作 SAFEARRAY 还不如直接用 VB。ilovehis () 查得怎么样了?