Platforms to show: All Mac Windows Linux Cross-Platform

Back to UUIDMBS class.

UUIDMBS.randomUUID as UUIDMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Util Plugin 13.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a random v4 GUID.
Example
for i as Integer = 1 to 20
Listbox1.AddRow UUIDMBS.randomUUID.ValueFormattedString
next

This is using random numbers.
It is unlikely, but possible to have duplicates.
The UUID function checks for that.

Some examples using this method:

UUIDMBS.UUID as UUIDMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Util Plugin 13.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a new UUID with system functions.

On Mac OS X: Uses CoreFoundation system functions from Mac OS X 10.3.
On Linux: Uses unix system functions (libuuid).
On Windows: Uses UUID functions from RPC functions (Rpcrt4.dll).

UUIDMBS.Validate(UUID as string, mode as Integer = 0, requiredVersion as Integer = 0) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Util Plugin 13.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Validates the given UUID/GUID.
Example
// wrong
dim w1 as string = UUIDMBS.Validate("hello") // wrong due to missing {
dim w2 as string = UUIDMBS.Validate("550e8400-z29b-11d4-a716-446655440000",1) // wrong with, with z
dim w3 as string = UUIDMBS.Validate("{550e8400-e29b-11d40716-446655440000}") // wrong with missing minus
dim w4 as string = UUIDMBS.Validate("{550e8400-e29b-11d4-a716-44665544000}") // wrong with being too short
dim w5 as string = UUIDMBS.Validate("{550e8400-e29b-11d4-a716-446655440000}dssdsd",1) // wrong as it has extra chars on end
dim w6 as string = UUIDMBS.Validate("550e8400-e29b-11d4-a716-446655440000",1,4) // wrong as not version 4
dim w7 as string = UUIDMBS.Validate("6a12a4d5-e9e6-4568-ffcc-34c70b24a668",1,4) // wrong as not version 4

// okay
dim o1 as string = UUIDMBS.Validate("550e8400-e29b-11d4-a716-446655440000",1)
dim o2 as string = UUIDMBS.Validate("{550e8400-e29b-11d4-a716-446655440000}")
dim o3 as string = UUIDMBS.Validate("6a12a4d5-e9e6-4568-afcc-34c70b24a668", 1)
dim o4 as string = UUIDMBS.Validate("6a12a4d5-e9e6-4568-afcc-34c70b24a668", 3)
dim o5 as string = UUIDMBS.Validate("{550e8400-e29b-11d4-a716-446655440000}", 2)
dim o6 as string = UUIDMBS.Validate("{550e8400e29b11d4a716446655440000}", 2)
dim o7 as string = UUIDMBS.Validate("{550e8400-e29b-11d40716-446655440000}",4) // wrong with missing minus, but fixed
dim o8 as string = UUIDMBS.Validate("550e8400-e29b-11d40716-446655440000}",4) // wrong with missing {, but fixed
dim o9 as string = UUIDMBS.Validate("6a12a4d5-e9e6-4568-afcc-34c70b24a668", 4, 4) // is version 4
dim o10 as string = UUIDMBS.Validate("6a12a4d5-e9e6-1568-afcc-34c70b24a668", 4, 1) // is version 1
dim o11 as string = UUIDMBS.Validate("{550e8400-e29b-11d4-a716-446655440000}dssdsd",1+4) // wrong as it has extra chars on end, but fixed

break // check in debugger

If the UUID is valid, you get it back.
If the UUID is invalid, you get an empty string back.

Pass 1 in mode to not require braces around UUID. Pass 2 to ignore minus characters. Pass 3 to combine those two.
You can add 4 to have the GUID fixed a bit like adding braces and minus chars if missing.
The requiredVersion parameter can be 1 to 5 to indicate the required GUID version you want to have.

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...