回答編集履歴
2
コード修正
test
CHANGED
@@ -38,4 +38,12 @@
|
|
38
38
|
|
39
39
|
End Function
|
40
40
|
|
41
|
+
|
42
|
+
|
43
|
+
Sub Test()
|
44
|
+
|
45
|
+
Debug.Print GetRansuu()
|
46
|
+
|
47
|
+
End Sub
|
48
|
+
|
41
49
|
```
|
1
コード追記
test
CHANGED
@@ -1 +1,41 @@
|
|
1
1
|
とりあえず8桁生成してみて、0~3が含まれているかチェックしてなければ再トライするというロジックでどうでしょう。
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```vba
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
Public Function GetRansuu() As String
|
10
|
+
|
11
|
+
Dim ransuu As String, cnt As Long, Num, ok As Boolean
|
12
|
+
|
13
|
+
Do
|
14
|
+
|
15
|
+
ransuu = ""
|
16
|
+
|
17
|
+
For cnt = 1 To 8
|
18
|
+
|
19
|
+
ransuu = ransuu & WorksheetFunction.RandBetween(0, 3)
|
20
|
+
|
21
|
+
Next
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
ok = True
|
26
|
+
|
27
|
+
For Each Num In Split("0 1 2 3")
|
28
|
+
|
29
|
+
ok = InStr(ransuu, Num) > 0
|
30
|
+
|
31
|
+
If ok = False Then Exit For
|
32
|
+
|
33
|
+
Next
|
34
|
+
|
35
|
+
Loop Until ok
|
36
|
+
|
37
|
+
GetRansuu = ransuu
|
38
|
+
|
39
|
+
End Function
|
40
|
+
|
41
|
+
```
|