質問するログイン新規登録

質問編集履歴

3

マルチポストへの対応

2018/12/05 04:13

投稿

kubocchi
kubocchi

スコア10

title CHANGED
File without changes
body CHANGED
@@ -151,4 +151,10 @@
151
151
  以上のコードをForm内に記載、ボタンを3つ並べ、Button1クリック時にTimer1のEnabledをTrueにし、Timer1_Tick内で Button2がクリックされるまでテキストファイルへの処理を繰り返し、Button3
152
152
  でアプリケーションを終了しています。
153
153
 
154
- ソースコードの開示方法がこれでよいか不安ですが、引き続きアドバイスの程よろしくお願い致します。
154
+ ソースコードの開示方法がこれでよいか不安ですが、引き続きアドバイスの程よろしくお願い致します。
155
+
156
+ --マルチポストについて
157
+  SurferOnWww様
158
+  恥ずかしながらご指摘を受けるまで「マルチポスト」を知りませんでした。
159
+  御無礼をお詫びいたしますと共に、MSDN側での質問は完了とさせて頂きました。
160
+  引き続きアドバイスの程よろしくお願い致します。

2

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

2018/12/05 04:13

投稿

kubocchi
kubocchi

スコア10

title CHANGED
File without changes
body CHANGED
@@ -9,7 +9,7 @@
9
9
  追記
10
10
  当該アプリケーションのソースコードを追加します。
11
11
 
12
- --以下
12
+ ```ここに言語を入力
13
13
  Imports System.Net
14
14
  Public Class Form1
15
15
  Public LogPath As String = ""
@@ -146,6 +146,7 @@
146
146
 
147
147
  End Sub
148
148
  End Class
149
+ ```
149
150
 
150
151
  以上のコードをForm内に記載、ボタンを3つ並べ、Button1クリック時にTimer1のEnabledをTrueにし、Timer1_Tick内で Button2がクリックされるまでテキストファイルへの処理を繰り返し、Button3
151
152
  でアプリケーションを終了しています。

1

ソースコードの追加

2018/12/05 00:03

投稿

kubocchi
kubocchi

スコア10

title CHANGED
File without changes
body CHANGED
@@ -4,4 +4,150 @@
4
4
 
5
5
  使用しているサーバはWindows Server 2012 R2、別セグメントに存在します。
6
6
 
7
- 当該エラーの発生原因をご教示下さい。
7
+ 当該エラーの発生原因をご教示下さい。
8
+
9
+ 追記
10
+ 当該アプリケーションのソースコードを追加します。
11
+
12
+ --以下
13
+ Imports System.Net
14
+ Public Class Form1
15
+ Public LogPath As String = ""
16
+ Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
17
+ (ByVal lpApplicationName As String, _
18
+ ByVal lpKeyName As String, _
19
+ ByVal lpDefault As String, _
20
+ ByVal lpReturnedString As String, _
21
+ ByVal nSize As Integer, _
22
+ ByVal lpFileName As String) As Long
23
+
24
+ Private Sub Button1_Click( sender As System.Object, e As System.EventArgs) Handles Button1.Click
25
+ If Timer1.Enabled = False then
26
+ Timer1.Enabled = True
27
+ End If
28
+
29
+ Button1.Enabled = False
30
+ Button2.Enabled = True
31
+ Button3.Enabled = False
32
+ End Sub
33
+
34
+ Private Sub Button2_Click( sender As System.Object, e As System.EventArgs) Handles Button2.Click
35
+ If Timer1.Enabled = True then
36
+ Timer1.Enabled = False
37
+ End If
38
+ Button1.Enabled = True
39
+ Button2.Enabled = False
40
+ Button3.Enabled = True
41
+ End Sub
42
+
43
+ Private Sub Button3_Click( sender As System.Object, e As System.EventArgs) Handles Button3.Click
44
+
45
+ If Timer1.Enabled = False then
46
+ End
47
+ End If
48
+
49
+ End Sub
50
+
51
+ Private Sub Form1_Load( sender As System.Object, e As System.EventArgs) Handles MyBase.Load
52
+
53
+ Timer1.Interval = 100
54
+ Timer1.Enabled = False
55
+ Button1.Enabled = True
56
+ Button2.Enabled = False
57
+ Button3.Enabled = True
58
+
59
+ Dim strResult As String = Space(255)
60
+
61
+ Call GetPrivateProfileString("WEB", "LOG", "", _
62
+ strResult, Len(strResult), _
63
+ "web.ini")
64
+ LogPath =GetIniFile("WEB", "LOG", "bsweb.ini")
65
+
66
+ End Sub
67
+
68
+ Private Sub Timer1_Tick( sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
69
+
70
+ Dim FName As String = ""
71
+ Dim fno As Integer
72
+ Dim HostName as String = ""
73
+
74
+ If Not NTGetHostName(HostName) then
75
+ End
76
+ End If
77
+
78
+ FName = LogPath & "\TEST_" & HostName & "_" & Now.ToString("yyyyMMdd") & ".log"
79
+
80
+ fno = FreeFile()
81
+
82
+ FileSystem.FileOpen(fno, FName, OpenMode.Append, OpenAccess.Write)
83
+
84
+ FileSystem.Print(fno, Now.ToString("yy/MM/dd HH:mm:ss") & vbCrLf)
85
+
86
+ FileSystem.FileClose(fno)
87
+
88
+ End Sub
89
+
90
+ Public Function GetIniFile(ByVal section As String, _
91
+ ByVal entry As String, _
92
+ ByVal iniFile As String) As String '!!
93
+
94
+ GetIniFile = GetIni(section, entry, GetAppPath() & "\" & iniFile)
95
+
96
+ Exit Function
97
+
98
+ End Function
99
+
100
+ Public Function GetIni(ByVal section As String, _
101
+ ByVal entry As String, _
102
+ ByVal iniFile As String) As String
103
+
104
+ Dim strResult As String = Space(255)
105
+
106
+ Call GetPrivateProfileString(section, entry, "", _
107
+ strResult, Len(strResult), _
108
+ iniFile)
109
+ GetIni = Microsoft.VisualBasic.Left(strResult, _
110
+ InStr(strResult, Chr(0)) - 1)
111
+ End Function
112
+
113
+ Private Function GetAppPath() As String
114
+ Return System.IO.Path.GetDirectoryName( _
115
+ System.Reflection.Assembly.GetExecutingAssembly().Location)
116
+ End Function
117
+
118
+ Public Function NTGetHostName(ByRef sHostName As String) As Boolean
119
+
120
+ Try
121
+ sHostName = Dns.GetHostName()
122
+ NTGetHostName = True
123
+
124
+ Catch ex As Exception
125
+ NTGetHostName = False
126
+ NTError()
127
+
128
+ End Try
129
+
130
+ End Function
131
+
132
+ Private Sub NTError(Optional ByVal sPlus As String = "")
133
+
134
+ Dim vErrMsg1 As String
135
+ Dim vRc As Integer
136
+
137
+ vErrMsg1 = strings.Right("000000" & Err.Number, 6) & ":" & Err.Description
138
+
139
+ If sPlus = "" Then
140
+ vErrMsg1 = vErrMsg1 & vbCrLf
141
+ Else
142
+ vErrMsg1 = vErrMsg1 & vbCrLf & "補足説明:" & sPlus
143
+ End If
144
+
145
+ vRc = MsgBox("ネットワークエラー" & vbCrLf & vErrMsg1, vbCritical)
146
+
147
+ End Sub
148
+ End Class
149
+
150
+ 以上のコードをForm内に記載、ボタンを3つ並べ、Button1クリック時にTimer1のEnabledをTrueにし、Timer1_Tick内で Button2がクリックされるまでテキストファイルへの処理を繰り返し、Button3
151
+ でアプリケーションを終了しています。
152
+
153
+ ソースコードの開示方法がこれでよいか不安ですが、引き続きアドバイスの程よろしくお願い致します。