Private Sub Command2_Click()    Dim aa As String * 10
    
    Dim Cc(100) As Byte
    Dim adr As Long
    
    aa = "1234567890"
    
    'adr = StrPtr(aa)
    CopyMemory ByVal aa, Cc(0), 8'///////
    MsgBox aaEnd Sub
估计是因为定长字符串的存储方式与普通字符串不同导致strptr不适用而致。

解决方案 »

  1.   

    定长字符串不能用StrPtr
    只能用VarPtr取得地址
      

  2.   

    Private Sub Command2_Click()
        Dim aa As String * 10
        Dim Cc(100) As Byte
        Dim adr As Long
        aa = "1234567890"
        adr = StrPtr(aa) - 4
        CopyMemory Cc(0), ByVal adr, 24
    End SubCc的结果是
    20  0  0  0  49  0  50  0  51  0  52  0  53  0  54  0  55  0  
    56  0  57  0  48  0
    所以我觉得StrPtr(aa)还是取到了定长字符串的地址阿
    可不知到为什么用这个地址给aa拷贝数据就是拷贝不上
    那位大侠知道定长字符串的存储方式阿