如下C程序,VB如何实现
void Test(unsigned char *p){
    MessageBox(p);
}
void Display(void){
    unsigned char s[20];
    strcpy((char *)s,"832476825");
    Test(s);
}

解决方案 »

  1.   

    function test(byref chararr() as string)
             msgbox join(chararr) 
    end functionfunction display()
           dim i as long  
            dim str as string
            s(19) as string
            str="832476825"
            for i=0 to len(str)
                if i<=19 then
                   s(i)=mid$(str,i,1) 
                end if 
            next
            call test(s)
    end function
      

  2.   

    我记得C中传数组就是把数组名(或数组第一个无素)和数组元数传给函数就OK
      

  3.   

    Function test(ByRef chararr() As String)
        MsgBox Join(chararr)
    End FunctionFunction display()
        Dim i As Long
        Dim str As String
        Dim s(19) As String
        
        str = "832476825"
        For i = 1 To Len(str)
            s(i) = Mid(str, i, 1)
        Next
        Call test(s)
    End Function
      

  4.   

    以上的朋友只是将数据强制转换为字符串,但我真正用的是传递通讯数据(不好意思无写清楚)例子如下:
    void  Test(unsigned  char  *p,int Len){  
        while(len--){
            串口=*p;     //将数据发送到串口
            p++;
        }
    }  
    void  Display(void){  
           unsigned  char  s[25]={1,2,3,137,5,6,7,8,9,0,
                                  1,2,3,21,4,12,45,56,56,245,
                                   89,167,191,161,12
                                  };  
           Test(s,20);  
    }
      

  5.   

    Private Sub Form_Load()
        Dim arr(10) As Byte
        Dim i As Integer
        
        For i = 1 To 10
            arr(i) = i
        Next
        
        i = aa(arr())
        Debug.Print i
        
    End SubPrivate Function aa(ar() As Byte) As Byte
        Debug.Print ar(3)
        aa = 5
    End Function输出
    3
    5