Convert a String to an number

  • Thread starter Thread starter 11Oppidan
  • Start date Start date
1

11Oppidan

Hi,

Using VB .Net please could someone help me with the syntax to convert a
string to number. I want this to turn the computer name into an value so I
can pass it through a function to determine a unique key for the machine.
 
How about using this function to get a unique number

Function DiskVolumeId() As String
Dim FSO As Object


Set FSO = CreateObject("Scripting.FileSystemObject")
DiskVolumeId = Format(CDbl(FSO.Drives("C:").SerialNumber­))
End Function


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
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.
 
Back
Top