View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter Huang [MSFT] Peter Huang [MSFT] is offline
external usenet poster
 
Posts: 225
Default Convert a String to an number

Hi

I think we may also try to compute the computername's md5 hash code which
is unique as long as the computername is different.

Imports System.Security.Cryptography
Module Module1
Public Function GetID(ByVal CompName As String) As Guid
Dim md As MD5 = New MD5CryptoServiceProvider
Dim hashcode() As Byte =
md.ComputeHash(System.Text.Encoding.ASCII.GetBytes (CompName))
Dim gd As Guid = New Guid(hashcode)
Return gd
End Function
Sub Main()
Dim CompNameA As String = "CompNameA"
Dim gd1 As Guid = GetID(CompNameA)
Dim CompNameB As String = "CompNameB"
Dim gd2 As Guid = GetID(CompNameB)
If gd1.CompareTo(gd2) = 0 Then
Console.WriteLine("True")
Else
Console.WriteLine("false")
End If
End Sub
End Module

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.