1
替換功能I得到這個錯誤:類型「字符串」的值不能轉化爲在VB
「字符串的1維陣列」當我嘗試使用替換功能,以取代 - 用一個空的空間時將文本轉換爲md5hash。
這是我的代碼:
Public Shared Function GetMD5Hash(ByVal TextToHash As String) As String
If TextToHash = "" Or TextToHash.Length = 0 Then
Return String.Empty
End If
Dim md5 As MD5 = New MD5CryptoServiceProvider()
Dim toHash As Byte() = Encoding.Default.GetBytes(TextToHash)
Dim result As Byte() = md5.ComputeHash(toHash)
Return System.BitConverter.ToString(result)
End Function
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim tempPassToken As String() = GetMD5Hash(TextBox2.Text).Replace("-", "")
Dim passMD5 As String = ""
For i = 0 To tempPassToken.Length - 1
passMD5 = passMD5 & tempPassToken(i)
Next
您正試圖將String分配給String()類型的變量。從tempPassToken中刪除括號,使其不是數組。這也消除了For循環的需要。 – 2013-04-07 20:58:15
感謝你的工作。 – 2013-04-08 18:22:31