|
-
Dec 10th, 2003, 06:55 PM
#1
Thread Starter
Frenzied Member
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
-
Dec 10th, 2003, 07:12 PM
#2
Hyperactive Member
Hi
Hope this helps you should work i just tested it
VB Code:
[color="#0000A0"]Dim[/color] A [color="#0000A0"]As[/color] [color="#0000A0"]String[/color]
[color="#0000A0"]Dim[/color] B [color="#0000A0"]As[/color] [color="#0000A0"]String[/color]
[color="#0000A0"]Dim[/color] C [color="#0000A0"]As[/color] [color="#0000A0"]String[/color]
A = InStr(1, txtStr, "{") + 1
B = InStr(A, txtStr, "}")
C = Mid$(txtStr, A, B - A)
MsgBox C
Born to help others
(If I've been helpful then please rate my post. Thanks)
call me EJ or be slapped! 
-
Dec 10th, 2003, 07:20 PM
#3
Fanatic Member
If it's always the first and last character of the string this code is easier:
VB Code:
Dim strGUID As String
strGUID = "{89eh-84h8-920d-93hd-94jd}"
MsgBox Mid(strGUID, 2, Len(strGUID) - 2)
Author for Visual Basic Web Magazine
-
Dec 10th, 2003, 07:32 PM
#4
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:
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.
-
Dec 10th, 2003, 09:34 PM
#5
Lively Member
Or, if {} are always going to be first and last,
VB Code:
strGUID = "{89eh-84h8-920d-93hd-94jd}"
strGUID = Left(strGUID, (Len(strGUID) - 1)
strGUID = Right(strGUID, (Len(strGUID) - 1)
-
Dec 11th, 2003, 11:45 AM
#6
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|