How to convert a GUID string to a GUID data type 
Author Message
 How to convert a GUID string to a GUID data type

I have a GUID that i convert to string and load into a listbox...now i want
to convert it back to a GUID to pass into a function...every convert routine
i try says you can't convert a string to a guid...what am i missing
here...HELP


Sun, 09 May 2004 04:26:43 GMT  
 How to convert a GUID string to a GUID data type
GUID has an overloaded constructor which takes a string.  So,

Dim t As Guid = New Guid("{03939458-iwgi98s9sd90ds0 etc . . .}")

--
Jacob Grass
Microsoft .NET MVP


Quote:
> I have a GUID that i convert to string and load into a listbox...now i
want
> to convert it back to a GUID to pass into a function...every convert
routine
> i try says you can't convert a string to a guid...what am i missing
> here...HELP



Sun, 09 May 2004 04:38:30 GMT  
 How to convert a GUID string to a GUID data type

Quote:
> I have a GUID that i convert to string and load into a listbox...now i want
> to convert it back to a GUID to pass into a function...every convert routine
> i try says you can't convert a string to a guid...what am i missing
> here...HELP

Look at the constructors for System.Guid
[code]
dim id as System.Guid
id = new System.Guid(strGuid)
[/code]

Mark



Sun, 09 May 2004 23:00:41 GMT  
 How to convert a GUID string to a GUID data type
Hi Mike,

or a different solution:
the Items collection of the ListBox takes objects and calls ToString() to
get the appropriate string. So you can add Guid-objects or objects of an
inherited class directly to the listbox:

private void Form1_Load(object sender, System.EventArgs e)
{
//Add some GUIDs to the listbox
Guid gid = Guid.NewGuid();
listBox1.Items.Add (gid);
gid = Guid.NewGuid();
listBox1.Items.Add (gid);

Quote:
}

private void listBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
//receive the selected
Guid gid = (Guid) listBox1.SelectedItem;
Quote:
}



Sun, 09 May 2004 23:32:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Converting a GUID data type to a String

2. sorry but again: GUID and AUTONUMBER (not GUID only, not AUTONUMBER only, but both)

3. To GUID or not to GUID...

4. Using a GUID as a Primary Key or indexing a GUID

5. AddNew with a GUID - can't get back the GUID

6. GUID - Reading the GUID of a file

7. ADODB select with GUID data type

8. Data type for GUID

9. GUID Convert

10. ADODB.Command Output Params return null for GUID types

11. How do I make VB recognize GUID type?

12. Error using GUID in SQL string for Domain Fuctions and dbs.OpenRecordset

 

 
Powered by phpBB® Forum Software