H heldenssjoerd Member Oct 16, 2020 #1 We're using the code below, based on the thread: [B4X] GUID Sub GUID As String Dim sb As StringBuilder sb.Initialize For Each stp As Int In Array(8, 4, 4, 4, 12) If sb.Length > 0 Then sb.Append("-") For n = 1 To stp Dim c As Int = Rnd(0, 16) If c < 10 Then c = c + 48 Else c = c + 55... www.b4x.com Code: Copy Sub GUID As String 'Dim stp As String = "00000000-0000-1000-a000-000000000000" 'original Dim stp As String = "00000000-0000-1000-a000-00000" 'little bit shorter then in the thread Dim sb As String = "" For Index = 0 To stp.Length-1 If stp.CharAt(Index)="0" Then sb=sb & "0123456789ABCDEF".CharAt(Rnd(0, 16)) Else sb=sb & stp.CharAt(Index) End If Next Return sb.ToUpperCase End Sub Now we where wondering when the same ID returns? If we compare this in our database along with date and programlicense wil it stay unique for (more than) a day? Our app is installed 500+ devices
We're using the code below, based on the thread: [B4X] GUID Sub GUID As String Dim sb As StringBuilder sb.Initialize For Each stp As Int In Array(8, 4, 4, 4, 12) If sb.Length > 0 Then sb.Append("-") For n = 1 To stp Dim c As Int = Rnd(0, 16) If c < 10 Then c = c + 48 Else c = c + 55... www.b4x.com Code: Copy Sub GUID As String 'Dim stp As String = "00000000-0000-1000-a000-000000000000" 'original Dim stp As String = "00000000-0000-1000-a000-00000" 'little bit shorter then in the thread Dim sb As String = "" For Index = 0 To stp.Length-1 If stp.CharAt(Index)="0" Then sb=sb & "0123456789ABCDEF".CharAt(Rnd(0, 16)) Else sb=sb & stp.CharAt(Index) End If Next Return sb.ToUpperCase End Sub Now we where wondering when the same ID returns? If we compare this in our database along with date and programlicense wil it stay unique for (more than) a day? Our app is installed 500+ devices
B Brian Dean Well-Known Member Licensed User Longtime User Oct 17, 2020 #2 If you were to allocate one of your reduced GUID values every second then you would have enough different values to last you one hundred billion times the life of the universe so far. This should give you some idea of the likelihood of repeating a value in the same day. Last edited: Oct 17, 2020 Upvote 0
If you were to allocate one of your reduced GUID values every second then you would have enough different values to last you one hundred billion times the life of the universe so far. This should give you some idea of the likelihood of repeating a value in the same day.