VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Check if a GUID is formatted properly

by Yannick Arekion (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 15th January 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Check if a GUID is formatted properly

API Declarations


' Author : Yannick Arekion
' Description : Determine if the value is a GUID
---

Rate Check if a GUID is formatted properly



     
    Dim ch As String
    Dim i As Integer
    
    IsGUID = True
    If Len(vGUID_IN) = 0 Then
        IsGUID = False
    ElseIf Left(vGUID_IN, 1) = "{" And Right(vGUID_IN, 1) = "}" Then
         For i = 2 To 37
          ch = Mid(vGUID_IN, i, 1)
          If i = 10 Or i = 15 Or i = 20 Or i = 25 Then
            If ch <> "-" Then
             IsGUID = False
            End If
          Else
           Select Case Asc(ch)
           'Print Asc(ch)
           Case 48 To 57   '0 -9
           Case 65 To 90  'A to Z
           Case 97 To 122 ' a - z
           Case Else
            IsGUID = False
           End Select
          End If
          If IsGUID = False Then
           i = 99
          End If
        Next
    Else
        IsGUID = False
    End If
    
End Function


Download this snippet    Add to My Saved Code

Check if a GUID is formatted properly Comments

No comments have been posted about Check if a GUID is formatted properly. Why not be the first to post a comment about Check if a GUID is formatted properly.

Post your comment

Subject:
Message:
0/1000 characters