Results 1 to 6 of 6

Thread: Remove curly braces from a GUID - [RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Remove curly braces from a GUID - [RESOLVED]

    I need a function that will strip the opening and closing curly braces from a GUID...I have tried using the Replace function (only good for replacing one character) and the Instr function (could get this to work)

    Any Ideas???

    Code:
    strGUID = "{89eh-84h8-920d-93hd-94jd}"
    
    I need it to remove the { and } and return just the 
    89eh-84h8-920d-93hd-94jd value
    Last edited by Memnoch1207; Dec 11th, 2003 at 11:46 AM.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  2. #2
    Hyperactive Member
    Join Date
    Nov 2003
    Location
    In Front of my computer...
    Posts
    367
    Hi

    Hope this helps you should work i just tested it

    VB Code:
    1. [color="#0000A0"]Dim[/color] A [color="#0000A0"]As[/color] [color="#0000A0"]String[/color]
    2. [color="#0000A0"]Dim[/color] B [color="#0000A0"]As[/color] [color="#0000A0"]String[/color]
    3. [color="#0000A0"]Dim[/color] C [color="#0000A0"]As[/color] [color="#0000A0"]String[/color]
    4. A = InStr(1, txtStr, "{") + 1
    5. B = InStr(A, txtStr, "}")
    6. C = Mid$(txtStr, A, B - A)
    7. MsgBox C
    Born to help others
    (If I've been helpful then please rate my post. Thanks)

    call me EJ or be slapped!

  3. #3
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    If it's always the first and last character of the string this code is easier:
    VB Code:
    1. Dim strGUID As String
    2. strGUID = "{89eh-84h8-920d-93hd-94jd}"
    3. MsgBox Mid(strGUID, 2, Len(strGUID) - 2)
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Remove curly braces from a GUID

    Originally posted by Memnoch1207
    I have tried using the Replace function (only good for replacing one character)
    For what it's worth:
    VB Code:
    1. MsgBox Replace(Replace("{89eh-84h8-920d-93hd-94jd}", "{", ""), "}", "")

    Also, If you use Mid() while working with String Data Types, then use the $ like: strBuff = Mid$()



    Bruce.

  5. #5
    Lively Member
    Join Date
    Feb 2003
    Posts
    117
    Or, if {} are always going to be first and last,

    VB Code:
    1. strGUID = "{89eh-84h8-920d-93hd-94jd}"
    2. strGUID = Left(strGUID, (Len(strGUID) - 1)
    3. strGUID = Right(strGUID, (Len(strGUID) - 1)

  6. #6

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    I went with this code.
    Code:
    Mid$(EID, 2, Len(EID) -2)
    but for some reason this
    Code:
    Replace(Replace("{89eh-84h8-920d-93hd-94jd}", "{", ""), "}", "")
    was generating an error.

    It's all finished, thanks for the help.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width