質問編集履歴
1
追記①を追加。
test
CHANGED
File without changes
|
test
CHANGED
@@ -93,3 +93,111 @@
|
|
93
93
|
前回の質問の続きになりますが、実現したいことと関係性はあまりないです。
|
94
94
|
|
95
95
|
https://teratail.com/questions/249014
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
### 追記①
|
100
|
+
|
101
|
+
ライブラリ側終了時にイベント発生、メイン側で受け取り処理をするというアドバイスをいただいて修正した後のソースコードです。
|
102
|
+
|
103
|
+
サブプロジェクト5のソースコードになります。(DB環境的に一番デバックしやすいため)
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
メインプロジェクト Menu.vb
|
108
|
+
|
109
|
+
```VB
|
110
|
+
|
111
|
+
Public Class Menu
|
112
|
+
|
113
|
+
'各システムのフォームインスタンスを格納するフィールド
|
114
|
+
|
115
|
+
Private SubProjectInstance1 As SubProject5.Form1
|
116
|
+
|
117
|
+
Private SubProjectInstance2 As SubProject5.Form2
|
118
|
+
|
119
|
+
Private SubProjectInstance3 As SubProject5.Form3
|
120
|
+
|
121
|
+
Private SubProjectInstance4 As SubProject5.Form4
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
Private Sub SubProject5_StartBTN_Click
|
126
|
+
|
127
|
+
'インスタンス生成
|
128
|
+
|
129
|
+
Me.SubProjectInstance1 = New SubProject5.Form1
|
130
|
+
|
131
|
+
Me.SubProjectInstance2 = New SubProject5.Form2
|
132
|
+
|
133
|
+
Me.SubProjectInstance3 = New SubProject5.Form3
|
134
|
+
|
135
|
+
Me.SubProjectInstance4 = New SubProject5.Form4
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
'イベントハンドラを設定
|
140
|
+
|
141
|
+
AddHandler SubProjectInstance1.SubProjectEnd, AddressOf SubProject_SubProjectEnd
|
142
|
+
|
143
|
+
AddHandler SubProjectInstance2.SubProjectEnd, AddressOf SubProject_SubProjectEnd
|
144
|
+
|
145
|
+
AddHandler SubProjectInstance3.SubProjectEnd, AddressOf SubProject_SubProjectEnd
|
146
|
+
|
147
|
+
AddHandler SubProjectInstance4.SubProjectEnd, AddressOf SubProject_SubProjectEnd
|
148
|
+
|
149
|
+
Ens Sub
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
Private Sub SubProject_SubProjectEnd(sender As Object, e As EventArgs)
|
154
|
+
|
155
|
+
'イベントハンドラを削除
|
156
|
+
|
157
|
+
RemoveHandler SubProjectInstance1.SubProjectEnd, AddressOf SubProject_SubProjectEnd
|
158
|
+
|
159
|
+
'メニュー画面を閉じて、ログイン画面を表示
|
160
|
+
|
161
|
+
Me.close()
|
162
|
+
|
163
|
+
Login.Show()
|
164
|
+
|
165
|
+
End Sub
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
End Class
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
サブプロジェクト Form2.vb
|
178
|
+
|
179
|
+
```VB
|
180
|
+
|
181
|
+
Public Class Form2
|
182
|
+
|
183
|
+
Public Event SubProjectEnd(sender As Object, e As EventArgs)
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
Private Sub CloseButton_Click(sender As Object, e As EventArgs) Handles CloseButton.Click
|
188
|
+
|
189
|
+
'Form2を閉じて、Endイベント発生
|
190
|
+
|
191
|
+
Me.Close()
|
192
|
+
|
193
|
+
RaiseEvent SubProjectEnd(Me, EventArgs.Empty)
|
194
|
+
|
195
|
+
End Sub
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
End Class
|
202
|
+
|
203
|
+
```
|