![]() |
Convert a String to an number
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. |
Convert a String to an number
"11Oppidan" wrote in message ... 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. Use CLng. You can find out more about conversion he http://www.startvbdotnet.com/language/conversion.aspx /Fredrik |
Convert a String to an number
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) "11Oppidan" wrote in message ... 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. |
Convert a String to an number
Thanks for your help - that seems a better option.
"Bob Phillips" wrote in message ... 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) "11Oppidan" wrote in message ... 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. |
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. |
All times are GMT +1. The time now is 02:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com