質問編集履歴
2
余分な文の削除
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,220 +6,212 @@
|
|
6
6
|
|
7
7
|
拙いコードですが、よろしくお願いします。
|
8
8
|
|
9
|
+
|
10
|
+
|
9
|
-
###
|
11
|
+
### 該当のソースコード
|
12
|
+
|
10
|
-
|
13
|
+
```VBnet
|
14
|
+
|
11
|
-
|
15
|
+
Public Class Form1
|
16
|
+
|
17
|
+
Inherits System.Windows.Forms.Form
|
18
|
+
|
19
|
+
Const SIKAKUNUM As Integer = 2 '四角の個数 定義
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
Dim ctr_pic(SIKAKUNUM) As PictureBox '画像を保持するクラス
|
24
|
+
|
25
|
+
Dim iti(SIKAKUNUM) As Sikaku '四角の位置を管理するクラス
|
26
|
+
|
27
|
+
Dim push As Boolean
|
28
|
+
|
29
|
+
Event switchmove(ByVal push As Boolean)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
Private Sub Button1_end_Click(sender As Object, e As EventArgs) Handles Button1_end.Click
|
34
|
+
|
35
|
+
'プログラムを終了する。
|
36
|
+
|
37
|
+
End
|
38
|
+
|
39
|
+
End Sub
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Private Sub Button2_start_Click(sender As Object, e As EventArgs) Handles Button2_start.Click
|
44
|
+
|
45
|
+
'移動スタート
|
46
|
+
|
47
|
+
Timer1.Enabled = True
|
48
|
+
|
49
|
+
End Sub
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load '起動時の処理
|
54
|
+
|
55
|
+
'画像をコードで表示する
|
56
|
+
|
57
|
+
Dim n As Integer
|
58
|
+
|
59
|
+
For n = 0 To SIKAKUNUM
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
'画像の位置を設定する
|
64
|
+
|
65
|
+
iti(n) = New Sikaku
|
66
|
+
|
67
|
+
iti(n).X = 80 * n
|
68
|
+
|
69
|
+
iti(n).Y = 50 * n
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
'画像コントロールを設定する・追加する
|
74
|
+
|
75
|
+
ctr_pic(n) = New PictureBox
|
76
|
+
|
77
|
+
With ctr_pic(n)
|
78
|
+
|
79
|
+
.Size = New Size(10, 10)
|
80
|
+
|
81
|
+
.Location = New Point(iti(n).X, iti(n).Y)
|
82
|
+
|
83
|
+
.Image = Image.FromFile("pic1.bmp")
|
84
|
+
|
85
|
+
End With
|
86
|
+
|
87
|
+
Me.Controls.Add(ctr_pic(n))
|
88
|
+
|
89
|
+
Next
|
90
|
+
|
91
|
+
End Sub
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
96
|
+
|
97
|
+
'四角を移動させる
|
98
|
+
|
99
|
+
Dim n As Integer
|
100
|
+
|
101
|
+
For n = 0 To SIKAKUNUM
|
102
|
+
|
103
|
+
iti(n).go(Me, push)
|
104
|
+
|
105
|
+
ctr_pic(n).Location = New Point(iti(n).X, iti(n).Y)
|
106
|
+
|
107
|
+
Next
|
108
|
+
|
109
|
+
End Sub
|
110
|
+
|
111
|
+
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
112
|
+
|
113
|
+
If push = False Then
|
114
|
+
|
115
|
+
push = True
|
116
|
+
|
117
|
+
Debug.WriteLine("click = True")
|
118
|
+
|
119
|
+
Else
|
120
|
+
|
121
|
+
push = False
|
122
|
+
|
123
|
+
Debug.WriteLine("click = False")
|
124
|
+
|
125
|
+
End If
|
126
|
+
|
127
|
+
End Sub
|
128
|
+
|
129
|
+
End Class
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
Public Class Sikaku
|
134
|
+
|
135
|
+
Inherits Form1
|
136
|
+
|
137
|
+
'四角の位置を管理するクラス 継承 From1
|
138
|
+
|
139
|
+
Private c_X As Integer
|
140
|
+
|
141
|
+
Private c_Y As Integer
|
142
|
+
|
143
|
+
'四角のX座標を保持するプロパティ
|
144
|
+
|
145
|
+
Public Property X() As Integer
|
146
|
+
|
147
|
+
Get
|
148
|
+
|
149
|
+
Return c_X
|
150
|
+
|
151
|
+
End Get
|
152
|
+
|
153
|
+
Set(ByVal Value As Integer)
|
154
|
+
|
155
|
+
c_X = Value
|
156
|
+
|
157
|
+
End Set
|
158
|
+
|
159
|
+
End Property
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
'四角のY座標を保持するプロパティ
|
164
|
+
|
165
|
+
Public Property Y() As Integer
|
166
|
+
|
167
|
+
Get
|
168
|
+
|
169
|
+
Return c_Y
|
170
|
+
|
171
|
+
End Get
|
172
|
+
|
173
|
+
Set(ByVal Value As Integer)
|
174
|
+
|
175
|
+
c_Y = Value
|
176
|
+
|
177
|
+
End Set
|
178
|
+
|
179
|
+
End Property
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
Public Sub go(ByVal basyo As Form, ByVal pushu As Boolean)
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
If pushu = True Then
|
188
|
+
|
189
|
+
'四角を動かすメソッド (X)
|
190
|
+
|
191
|
+
c_X = c_X + 10
|
192
|
+
|
193
|
+
If c_X > basyo.Size.Width - 10 Then 'Width 横の長さ。
|
194
|
+
|
195
|
+
c_X = 0
|
196
|
+
|
197
|
+
End If
|
198
|
+
|
199
|
+
Else
|
200
|
+
|
201
|
+
'四角を動かすメソッド (Y)
|
202
|
+
|
203
|
+
c_Y = c_Y + 10
|
204
|
+
|
205
|
+
If c_Y > basyo.Size.Height - 10 Then 'Height 高さを取得する。
|
206
|
+
|
207
|
+
c_Y = 0
|
208
|
+
|
209
|
+
End If
|
210
|
+
|
211
|
+
End If
|
212
|
+
|
213
|
+
End Sub
|
214
|
+
|
215
|
+
End Class
|
12
216
|
|
13
217
|
```
|
14
|
-
|
15
|
-
エラーメッセージ
|
16
|
-
|
17
|
-
```
|
18
|
-
|
19
|
-
### 該当のソースコード
|
20
|
-
|
21
|
-
```VBnet
|
22
|
-
|
23
|
-
Public Class Form1
|
24
|
-
|
25
|
-
Inherits System.Windows.Forms.Form
|
26
|
-
|
27
|
-
Const SIKAKUNUM As Integer = 2 '四角の個数 定義
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
Dim ctr_pic(SIKAKUNUM) As PictureBox '画像を保持するクラス
|
32
|
-
|
33
|
-
Dim iti(SIKAKUNUM) As Sikaku '四角の位置を管理するクラス
|
34
|
-
|
35
|
-
Dim push As Boolean
|
36
|
-
|
37
|
-
Event switchmove(ByVal push As Boolean)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Private Sub Button1_end_Click(sender As Object, e As EventArgs) Handles Button1_end.Click
|
42
|
-
|
43
|
-
'プログラムを終了する。
|
44
|
-
|
45
|
-
End
|
46
|
-
|
47
|
-
End Sub
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Private Sub Button2_start_Click(sender As Object, e As EventArgs) Handles Button2_start.Click
|
52
|
-
|
53
|
-
'移動スタート
|
54
|
-
|
55
|
-
Timer1.Enabled = True
|
56
|
-
|
57
|
-
End Sub
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load '起動時の処理
|
62
|
-
|
63
|
-
'画像をコードで表示する
|
64
|
-
|
65
|
-
Dim n As Integer
|
66
|
-
|
67
|
-
For n = 0 To SIKAKUNUM
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
'画像の位置を設定する
|
72
|
-
|
73
|
-
iti(n) = New Sikaku
|
74
|
-
|
75
|
-
iti(n).X = 80 * n
|
76
|
-
|
77
|
-
iti(n).Y = 50 * n
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
'画像コントロールを設定する・追加する
|
82
|
-
|
83
|
-
ctr_pic(n) = New PictureBox
|
84
|
-
|
85
|
-
With ctr_pic(n)
|
86
|
-
|
87
|
-
.Size = New Size(10, 10)
|
88
|
-
|
89
|
-
.Location = New Point(iti(n).X, iti(n).Y)
|
90
|
-
|
91
|
-
.Image = Image.FromFile("pic1.bmp")
|
92
|
-
|
93
|
-
End With
|
94
|
-
|
95
|
-
Me.Controls.Add(ctr_pic(n))
|
96
|
-
|
97
|
-
Next
|
98
|
-
|
99
|
-
End Sub
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
|
104
|
-
|
105
|
-
'四角を移動させる
|
106
|
-
|
107
|
-
Dim n As Integer
|
108
|
-
|
109
|
-
For n = 0 To SIKAKUNUM
|
110
|
-
|
111
|
-
iti(n).go(Me, push)
|
112
|
-
|
113
|
-
ctr_pic(n).Location = New Point(iti(n).X, iti(n).Y)
|
114
|
-
|
115
|
-
Next
|
116
|
-
|
117
|
-
End Sub
|
118
|
-
|
119
|
-
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
120
|
-
|
121
|
-
If push = False Then
|
122
|
-
|
123
|
-
push = True
|
124
|
-
|
125
|
-
Debug.WriteLine("click = True")
|
126
|
-
|
127
|
-
Else
|
128
|
-
|
129
|
-
push = False
|
130
|
-
|
131
|
-
Debug.WriteLine("click = False")
|
132
|
-
|
133
|
-
End If
|
134
|
-
|
135
|
-
End Sub
|
136
|
-
|
137
|
-
End Class
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
Public Class Sikaku
|
142
|
-
|
143
|
-
Inherits Form1
|
144
|
-
|
145
|
-
'四角の位置を管理するクラス 継承 From1
|
146
|
-
|
147
|
-
Private c_X As Integer
|
148
|
-
|
149
|
-
Private c_Y As Integer
|
150
|
-
|
151
|
-
'四角のX座標を保持するプロパティ
|
152
|
-
|
153
|
-
Public Property X() As Integer
|
154
|
-
|
155
|
-
Get
|
156
|
-
|
157
|
-
Return c_X
|
158
|
-
|
159
|
-
End Get
|
160
|
-
|
161
|
-
Set(ByVal Value As Integer)
|
162
|
-
|
163
|
-
c_X = Value
|
164
|
-
|
165
|
-
End Set
|
166
|
-
|
167
|
-
End Property
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
'四角のY座標を保持するプロパティ
|
172
|
-
|
173
|
-
Public Property Y() As Integer
|
174
|
-
|
175
|
-
Get
|
176
|
-
|
177
|
-
Return c_Y
|
178
|
-
|
179
|
-
End Get
|
180
|
-
|
181
|
-
Set(ByVal Value As Integer)
|
182
|
-
|
183
|
-
c_Y = Value
|
184
|
-
|
185
|
-
End Set
|
186
|
-
|
187
|
-
End Property
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
Public Sub go(ByVal basyo As Form, ByVal pushu As Boolean)
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
If pushu = True Then
|
196
|
-
|
197
|
-
'四角を動かすメソッド (X)
|
198
|
-
|
199
|
-
c_X = c_X + 10
|
200
|
-
|
201
|
-
If c_X > basyo.Size.Width - 10 Then 'Width 横の長さ。
|
202
|
-
|
203
|
-
c_X = 0
|
204
|
-
|
205
|
-
End If
|
206
|
-
|
207
|
-
Else
|
208
|
-
|
209
|
-
'四角を動かすメソッド (Y)
|
210
|
-
|
211
|
-
c_Y = c_Y + 10
|
212
|
-
|
213
|
-
If c_Y > basyo.Size.Height - 10 Then 'Height 高さを取得する。
|
214
|
-
|
215
|
-
c_Y = 0
|
216
|
-
|
217
|
-
End If
|
218
|
-
|
219
|
-
End If
|
220
|
-
|
221
|
-
End Sub
|
222
|
-
|
223
|
-
End Class
|
224
|
-
|
225
|
-
```
|
1
コードの挿入追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,10 +16,10 @@
|
|
16
16
|
|
17
17
|
```
|
18
18
|
|
19
|
-
|
20
|
-
|
21
19
|
### 該当のソースコード
|
22
20
|
|
21
|
+
```VBnet
|
22
|
+
|
23
23
|
Public Class Form1
|
24
24
|
|
25
25
|
Inherits System.Windows.Forms.Form
|
@@ -221,3 +221,5 @@
|
|
221
221
|
End Sub
|
222
222
|
|
223
223
|
End Class
|
224
|
+
|
225
|
+
```
|