Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-07-2009
Member
 
Join Date: Dec 2008
Posts: 20
How to Convert a String to GUID

Hello, I Want to convert a String in Guid , can you tell me How Can i Convert String to Guid Using Csharp (c#) or Vb.net (preferably) ,please tell me How can i implement these function Using Any other Software , Thanks in advance
Reply With Quote
  #2  
Old 07-07-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: How to Convert a String to GUID

StringFromGUID
StringFromGUID function converts a globally unique identifier (GUID), which is an array of type Byte, in a chain.

or

Try
Code:
      gID = New Guid(myString)
    Catch ex As Exception
      gID = Guid.Empty
    End Try
Reply With Quote
  #3  
Old 07-07-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to Convert a String to GUID

To convert a string to a GUID, do the following:

In C#:
Guid MyGuid = new Guid(stringValue);

And in VB .NET:
Dim MyGuid As Guid = New Guid(stringValue)
Reply With Quote
  #4  
Old 07-07-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: How to Convert a String to GUID

GUIDFromString Function - Deprecated. Converts a string to a GUID.

Note Applications should use CLSIDFromString or IIDFromString in place of this function.

Syntax
Code:
BOOL GUIDFromString(      
    LPCTSTR psz,
    LPGUID pguid
);

Parameters
Code:
psz
[in] A pointer to the null-terminated string to convert. The string should be in the following form: 
{00000000-0000-0000-0000-000000000000}
pguid
[out] Pointer to a buffer to receive the GUID when this method returns.
Return Value
TRUE if the GUID was created successfully; otherwise, FALSE.


TRUE if the GUID was created successfully; otherwise, FALSE.

Remarks
Note GUIDFromString is available through Microsoft Windows XP Service Pack 2 (SP2) or Windows Vista. It might be altered or unavailable in subsequent versions. This function is not declared in a header or exported by name from a .dll file. It must be loaded from Shell32.dll as ordinal 703 for GUIDFromStringA and ordinal 704 for GUIDFromStringW.

It can also be accessed from Shlwapi.dll as ordinal 269 for GUIDFromStringA and ordinal 270 for GUIDFromString
Reply With Quote
  #5  
Old 07-07-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: How to Convert a String to GUID

To convert a string to GUID, you must do the following:

Code:
String strValue; 
Guid objGUID; 
strValue = "(80E9CEF7-1C93-48A7-866C-2002F94379E6)"; 
objGUID = new Guid (strValue);
Practically if you have a GUID as a value to an HTML element and this must stop at the end back into an object attribute would like to pack up.
Reply With Quote
  #6  
Old 07-07-2009
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: How to Convert a String to GUID

The following example uses the GUIDFromString function to convert a string to a GUID. The string is a GUID stored in string form in a replicated Employees table. The field, s_GUID, is a hidden field added to every replicated table in a replicated database.

Quote:
Sub CheckGUIDType()

Dim dbsConn As ADODB.Connection
Dim rstEmployees As ADODB.Recordset

' Make a connection to the current database.
Set dbsConn = Application.CurrentProject.Connection
Set rstEmployees = New ADODB.Recordset
rstEmployees.Open "Employees", _
dbsConn, , , adCmdTable

' Print the GUID to the immediate window.
Debug.Print rst!s_GUID
Debug.Print TypeName(rst!s_GUID)
Debug.Print TypeName(GuidFromString(rst!s_GUID))

Set rstEmployees = Nothing
Set dbsConn = Nothing

End Sub
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to Convert a String to GUID"
Thread Thread Starter Forum Replies Last Post
Convert string into int in C screwball Software Development 4 22-12-2011 08:47 PM
Convert XML string into DOM GreatThinker Software Development 6 22-07-2010 09:48 AM
Convert String to filename Maya Angelou Software Development 5 12-03-2010 01:20 PM
How to convert string into DateTime Segvoia Software Development 7 05-03-2010 02:55 PM
How to convert string to int Zavier Software Development 3 04-06-2009 06:24 PM


All times are GMT +5.5. The time now is 05:19 PM.