| a | b | |
|---|
| 0 | + | Sub StringShuffle() |
|---|
| 0 | + | ThisComponent.CurrentSelection.FormulaArray = ArrayShuffle(ThisComponent.CurrentSelection.FormulaArray) |
|---|
| 0 | + | End Sub |
|---|
| 0 | + | |
|---|
| 0 | + | Function ArrayRange(ByVal min, ByVal max) |
|---|
| 0 | + | Dim len |
|---|
| 0 | + | len = max - min |
|---|
| 0 | + | Dim res(len - 1) |
|---|
| 0 | + | Dim n |
|---|
| 0 | + | n = min |
|---|
| 0 | + | Dim i |
|---|
| 0 | + | For i = 0 To UBound(res) |
|---|
| 0 | + | res(i) = n |
|---|
| 0 | + | n = n + 1 |
|---|
| 0 | + | Next |
|---|
| 0 | + | ArrayRange = res |
|---|
| 0 | + | End Function |
|---|
| 0 | + | |
|---|
| 0 | + | Function NumberRandom(ByVal min, ByVal max) |
|---|
| 0 | + | Dim len |
|---|
| 0 | + | len = max - min |
|---|
| 0 | + | Dim res |
|---|
| 0 | + | res = Int(Rnd() * len) + min |
|---|
| 0 | + | NumberRandom = res |
|---|
| 0 | + | End Function |
|---|
| 0 | + | |
|---|
| 0 | + | Function ArrayShuffle(ByVal src()) |
|---|
| 0 | + | Dim res |
|---|
| 0 | + | res = ArrayCopy(src) |
|---|
| 0 | + | Dim t |
|---|
| 0 | + | Dim j |
|---|
| 0 | + | Dim u |
|---|
| 0 | + | u = UBound(res) |
|---|
| 0 | + | For i = u To 1 Step -1 |
|---|
| 0 | + | j = NumberRandom(0, i + 1) |
|---|
| 0 | + | t = res(j) |
|---|
| 0 | + | res(j) = res(i) |
|---|
| 0 | + | res(i) = t |
|---|
| 0 | + | Next |
|---|
| 0 | + | ArrayShuffle = res |
|---|
| 0 | + | End Function |
|---|
| 0 | + | |
|---|
| 0 | + | Function ArrayCopy(ByVal src()) |
|---|
| 0 | + | Dim res(UBound(src)) |
|---|
| 0 | + | For i = 0 To UBound(res) |
|---|
| 0 | + | res(i) = src(i) |
|---|
| 0 | + | Next |
|---|
| 0 | + | ArrayCopy = res |
|---|
| 0 | + | End Function |
|---|
| ... | |
|---|