Revision 376262666637 () - Diff

Link to this snippet: https://friendpaste.com/4vZfvOpbipg85Oke2QgG8Q
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Sub StringShuffle()
ThisComponent.CurrentSelection.FormulaArray = ArrayShuffle(ThisComponent.CurrentSelection.FormulaArray)
End Sub

Function ArrayShuffle(ByVal src())
Dim res
res = ArrayCopy(src)
Dim i
For i = UBound(res) To 1 Step -1
Dim j
j = NumberRandom(0, i + 1)
Dim t
t = res(j)
res(j) = res(i)
res(i) = t
Next
ArrayShuffle = res
End Function

Function ArrayCopy(ByVal src())
Dim res(UBound(src))
Dim i
For i = 0 To UBound(res)
res(i) = src(i)
Next
ArrayCopy = res
End Function

Function NumberRandom(ByVal min, ByVal max)
Dim len
len = max - min
Dim res
res = Int(Rnd() * len) + min
NumberRandom = res
End Function