質問編集履歴

3

マルチポストへの対応

2018/12/05 04:13

投稿

kubocchi
kubocchi

スコア10

test CHANGED
File without changes
test CHANGED
@@ -305,3 +305,15 @@
305
305
 
306
306
 
307
307
  ソースコードの開示方法がこれでよいか不安ですが、引き続きアドバイスの程よろしくお願い致します。
308
+
309
+
310
+
311
+ --マルチポストについて
312
+
313
+  SurferOnWww様
314
+
315
+  恥ずかしながらご指摘を受けるまで「マルチポスト」を知りませんでした。
316
+
317
+  御無礼をお詫びいたしますと共に、MSDN側での質問は完了とさせて頂きました。
318
+
319
+  引き続きアドバイスの程よろしくお願い致します。

2

ソースコード記載方法を変更しました

2018/12/05 04:13

投稿

kubocchi
kubocchi

スコア10

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
 
22
22
 
23
- --以下
23
+ ```ここに言語を入力
24
24
 
25
25
  Imports System.Net
26
26
 
@@ -294,6 +294,8 @@
294
294
 
295
295
  End Class
296
296
 
297
+ ```
298
+
297
299
 
298
300
 
299
301
  以上のコードをForm内に記載、ボタンを3つ並べ、Button1クリック時にTimer1のEnabledをTrueにし、Timer1_Tick内で Button2がクリックされるまでテキストファイルへの処理を繰り返し、Button3

1

ソースコードの追加

2018/12/05 00:03

投稿

kubocchi
kubocchi

スコア10

test CHANGED
File without changes
test CHANGED
@@ -11,3 +11,295 @@
11
11
 
12
12
 
13
13
  当該エラーの発生原因をご教示下さい。
14
+
15
+
16
+
17
+ 追記
18
+
19
+ 当該アプリケーションのソースコードを追加します。
20
+
21
+
22
+
23
+ --以下
24
+
25
+ Imports System.Net
26
+
27
+ Public Class Form1
28
+
29
+ Public LogPath As String = ""
30
+
31
+ Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
32
+
33
+ (ByVal lpApplicationName As String, _
34
+
35
+ ByVal lpKeyName As String, _
36
+
37
+ ByVal lpDefault As String, _
38
+
39
+ ByVal lpReturnedString As String, _
40
+
41
+ ByVal nSize As Integer, _
42
+
43
+ ByVal lpFileName As String) As Long
44
+
45
+
46
+
47
+ Private Sub Button1_Click( sender As System.Object, e As System.EventArgs) Handles Button1.Click
48
+
49
+ If Timer1.Enabled = False then
50
+
51
+ Timer1.Enabled = True
52
+
53
+ End If
54
+
55
+
56
+
57
+ Button1.Enabled = False
58
+
59
+ Button2.Enabled = True
60
+
61
+ Button3.Enabled = False
62
+
63
+ End Sub
64
+
65
+
66
+
67
+ Private Sub Button2_Click( sender As System.Object, e As System.EventArgs) Handles Button2.Click
68
+
69
+ If Timer1.Enabled = True then
70
+
71
+ Timer1.Enabled = False
72
+
73
+ End If
74
+
75
+ Button1.Enabled = True
76
+
77
+ Button2.Enabled = False
78
+
79
+ Button3.Enabled = True
80
+
81
+ End Sub
82
+
83
+
84
+
85
+ Private Sub Button3_Click( sender As System.Object, e As System.EventArgs) Handles Button3.Click
86
+
87
+
88
+
89
+ If Timer1.Enabled = False then
90
+
91
+ End
92
+
93
+ End If
94
+
95
+
96
+
97
+ End Sub
98
+
99
+
100
+
101
+ Private Sub Form1_Load( sender As System.Object, e As System.EventArgs) Handles MyBase.Load
102
+
103
+
104
+
105
+ Timer1.Interval = 100
106
+
107
+ Timer1.Enabled = False
108
+
109
+ Button1.Enabled = True
110
+
111
+ Button2.Enabled = False
112
+
113
+ Button3.Enabled = True
114
+
115
+
116
+
117
+ Dim strResult As String = Space(255)
118
+
119
+
120
+
121
+ Call GetPrivateProfileString("WEB", "LOG", "", _
122
+
123
+ strResult, Len(strResult), _
124
+
125
+ "web.ini")
126
+
127
+ LogPath =GetIniFile("WEB", "LOG", "bsweb.ini")
128
+
129
+
130
+
131
+ End Sub
132
+
133
+
134
+
135
+ Private Sub Timer1_Tick( sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
136
+
137
+
138
+
139
+ Dim FName As String = ""
140
+
141
+ Dim fno As Integer
142
+
143
+ Dim HostName as String = ""
144
+
145
+
146
+
147
+ If Not NTGetHostName(HostName) then
148
+
149
+ End
150
+
151
+ End If
152
+
153
+
154
+
155
+ FName = LogPath & "\TEST_" & HostName & "_" & Now.ToString("yyyyMMdd") & ".log"
156
+
157
+
158
+
159
+ fno = FreeFile()
160
+
161
+
162
+
163
+ FileSystem.FileOpen(fno, FName, OpenMode.Append, OpenAccess.Write)
164
+
165
+
166
+
167
+ FileSystem.Print(fno, Now.ToString("yy/MM/dd HH:mm:ss") & vbCrLf)
168
+
169
+
170
+
171
+ FileSystem.FileClose(fno)
172
+
173
+
174
+
175
+ End Sub
176
+
177
+
178
+
179
+ Public Function GetIniFile(ByVal section As String, _
180
+
181
+ ByVal entry As String, _
182
+
183
+ ByVal iniFile As String) As String '!!
184
+
185
+
186
+
187
+ GetIniFile = GetIni(section, entry, GetAppPath() & "\" & iniFile)
188
+
189
+
190
+
191
+ Exit Function
192
+
193
+
194
+
195
+ End Function
196
+
197
+
198
+
199
+ Public Function GetIni(ByVal section As String, _
200
+
201
+ ByVal entry As String, _
202
+
203
+ ByVal iniFile As String) As String
204
+
205
+
206
+
207
+ Dim strResult As String = Space(255)
208
+
209
+
210
+
211
+ Call GetPrivateProfileString(section, entry, "", _
212
+
213
+ strResult, Len(strResult), _
214
+
215
+ iniFile)
216
+
217
+ GetIni = Microsoft.VisualBasic.Left(strResult, _
218
+
219
+ InStr(strResult, Chr(0)) - 1)
220
+
221
+ End Function
222
+
223
+
224
+
225
+ Private Function GetAppPath() As String
226
+
227
+ Return System.IO.Path.GetDirectoryName( _
228
+
229
+ System.Reflection.Assembly.GetExecutingAssembly().Location)
230
+
231
+ End Function
232
+
233
+
234
+
235
+ Public Function NTGetHostName(ByRef sHostName As String) As Boolean
236
+
237
+
238
+
239
+ Try
240
+
241
+ sHostName = Dns.GetHostName()
242
+
243
+ NTGetHostName = True
244
+
245
+
246
+
247
+ Catch ex As Exception
248
+
249
+ NTGetHostName = False
250
+
251
+ NTError()
252
+
253
+
254
+
255
+ End Try
256
+
257
+
258
+
259
+ End Function
260
+
261
+
262
+
263
+ Private Sub NTError(Optional ByVal sPlus As String = "")
264
+
265
+
266
+
267
+ Dim vErrMsg1 As String
268
+
269
+ Dim vRc As Integer
270
+
271
+
272
+
273
+ vErrMsg1 = strings.Right("000000" & Err.Number, 6) & ":" & Err.Description
274
+
275
+
276
+
277
+ If sPlus = "" Then
278
+
279
+ vErrMsg1 = vErrMsg1 & vbCrLf
280
+
281
+ Else
282
+
283
+ vErrMsg1 = vErrMsg1 & vbCrLf & "補足説明:" & sPlus
284
+
285
+ End If
286
+
287
+
288
+
289
+ vRc = MsgBox("ネットワークエラー" & vbCrLf & vErrMsg1, vbCritical)
290
+
291
+
292
+
293
+ End Sub
294
+
295
+ End Class
296
+
297
+
298
+
299
+ 以上のコードをForm内に記載、ボタンを3つ並べ、Button1クリック時にTimer1のEnabledをTrueにし、Timer1_Tick内で Button2がクリックされるまでテキストファイルへの処理を繰り返し、Button3
300
+
301
+ でアプリケーションを終了しています。
302
+
303
+
304
+
305
+ ソースコードの開示方法がこれでよいか不安ですが、引き続きアドバイスの程よろしくお願い致します。