Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.






  #5   Report Post  
Posted to microsoft.public.excel.programming
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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a number to a text string Sandy Excel Worksheet Functions 4 January 3rd 08 08:43 PM
convert string to number Jeff Klein Excel Worksheet Functions 4 November 1st 07 10:01 PM
Convert a number to a name string Numbers to name string Excel Worksheet Functions 2 June 23rd 06 04:52 PM
How to COnvert text string to number timtak Excel Discussion (Misc queries) 3 June 4th 05 04:57 AM
convert string to number Christina Excel Worksheet Functions 3 November 16th 04 02:36 PM


All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"