不明白为什么老是出现异常?
Private Function MD5StringArray(strInput As String) As Byte()
  
    Dim intLoop As Integer
    Dim bytbuffer() As Byte
    ReDim bytbuffer(Len(strInput))
    
    For intLoop = 0 To Len(strInput) - 1
        bytbuffer(intLoop) = Asc(Mid(strInput, intLoop + 1, 1))
    Next intLoop
    
    MD5StringArray = bytbuffer
    
End Function

解决方案 »

  1.   

    //bytbuffer(intLoop) = Asc(Mid(strInput, intLoop + 1, 1))
    是不是strInput含有中文啊
      

  2.   

    顺便说一句,在VB中,string可以直接赋值给一个byte数组
      

  3.   

    BlueBeer(1win):
    strInput中没有中文的。
      

  4.   

    bytbuffer 是bety是不是strInput包含了非ascii码的字符啊
      

  5.   

    不能包含非ASCII码的字符,同样也不能包含中文
    最好用StrConv(strInput, vbUnicode)转换成unicode格式。
      

  6.   

    Private Function MD5StringArray(strInput As String) As Byte()
      
        Dim bytbuffer() As Byte
        bytbuffer = StrConv(strInput, vbFromUnicode)    
        MD5StringArray = bytbuffer
        
    End Function