Results 1 to 6 of 6

Thread: How to Convert a String to GUID

  1. #1
    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

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    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

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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)

  4. #4
    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

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    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.

  6. #6
    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.

    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

Similar Threads

  1. Convert string into int in C
    By screwball in forum Software Development
    Replies: 4
    Last Post: 22-12-2011, 08:47 PM
  2. Convert XML string into DOM
    By GreatThinker in forum Software Development
    Replies: 6
    Last Post: 22-07-2010, 09:48 AM
  3. Convert String to filename
    By Maya Angelou in forum Software Development
    Replies: 5
    Last Post: 12-03-2010, 01:20 PM
  4. How to convert string into DateTime
    By Segvoia in forum Software Development
    Replies: 7
    Last Post: 05-03-2010, 02:55 PM
  5. How to convert string to int
    By Zavier in forum Software Development
    Replies: 3
    Last Post: 04-06-2009, 06:24 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,718,677,066.32563 seconds with 17 queries