-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeneral
313 lines (225 loc) · 9.42 KB
/
General
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' General (Module)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'Tag for the user's home page
Const tagHome As String = " BNIMAIN"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RestrictToPositiveWholeNumbers
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub RestrictToPostiveWholeNumbers(KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Else
KeyAscii = 0
End Select
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' RestrictToPostiveFloatNumbers
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub RestrictToPostiveFloatNumbers(KeyAscii As MSForms.ReturnInteger, str_textbox As String)
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Asc(".")
If InStr(1, str_textbox, ".") > 0 Then
KeyAscii = 0
End If
Case Else
KeyAscii = 0
End Select
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TurnOffExcelDefaults
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub TurnOffExcelDefaults(Optional ByRef Exception As cException)
'Pass error handling up the call stack
On Error GoTo 0
If Not Exception Is Nothing Then Exception.Push "General.TurnOffExcelDefaults"
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Cleanup:
If Not Exception Is Nothing Then Exception.Pop
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' TurnOnExcelDefaults
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub TurnOnExcelDefaults(Optional ByRef Exception As cException)
'Pass error handling up the call stack
On Error GoTo 0
If Not Exception Is Nothing Then Exception.Push "General.TurnOnExcelDefaults"
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Cleanup:
If Not Exception Is Nothing Then Exception.Pop
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' NavigateHome
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub NavigateHome(ByVal AS400 As cAS400, ByRef Exception As cException)
'Pass error handling up the call stack
On Error GoTo 0
Exception.Push "General.NavigateHome"
Dim i As Integer 'Loop counter
Const maxAttempts As Integer = 5 'Max loop count
Const rowHome As Long = 19 'Navigation entry
Const colHome As Long = 7 'Navigation entry
Const tagLength As Long = 8 'Location of page tag
Const tagRow As Long = 1 'Location of page tag
Const tagCol As Long = 2 'Location of page tag
Exception.ErrMessage = "Starting the navigation loop"
Do
AS400.Pause
Select Case AS400.GetText(tagRow, tagCol, tagLength)
'PS: BNIMAIN (Destination)
Case Is = tagHome
'Note: Certain screens have a "pop-up" screen _
that must be F3'd out of as well
AS400.SendKeys F3Key
Exit Do
'PS: BNICS
Case " BNICS "
AS400.SendKeys F12Key
Exit Do
'PS: 66300
Case " 66300 "
AS400.SendKeys F3Key
'PS: 66340
Case " 66340 "
AS400.SendKeys F3Key
'PS: Student Service Inquiry (1.14.)
Case "603131_B"
AS400.SendKeys F3Key
'Address Book Information
Case "01051 "
AS400.SendKeys F3Key
'PS: (1.14.), Customer Ledger Inquiry
Case " 032002 "
AS400.SendKeys F3Key
'PS: (1.14.), ICS Cancellation Maintenance
Case "631001 "
AS400.SendKeys F3Key
'PS: (1.14.), Student Supplemental
Case "60110 "
AS400.SendKeys F3Key
'PS: (1.14.), Student Course Master
Case "60210 "
AS400.SendKeys F3Key
Case "60211 "
AS400.SendKeys F3Key
AS400.SendKeys F3Key
'PS: (1.14.), Shipping Screen
Case "42045 "
AS400.SendKeys F3Key
'PS: ICS Accounting Main Menu
Case " ICSACCT"
AS400.SendKeys F12Key
'PS: Main Menu
Case "ICSMAIN "
AS400.Pause
AS400.SetText "6", 20, 7
AS400.SendKeys EnterKey
'Library List Selection
Case " 98VL "
AS400.Pause
AS400.SetText "1", 6, 10
AS400.SendKeys EnterKey
'Product File Maintenance
Case " BNIPROD"
AS400.SendKeys F12Key
'Note Maintenance
Case " 55192 "
AS400.SendKeys F3Key
'Education Screen
Case " 55192 "
AS400.SendKeys F3Key
'Name Search
Case "603132_B"
AS400.SendKeys F3Key
Case "631001 "
AS400.SendKeys F3Key
AS400.SendKeys F3Key
Case " BNISOP "
AS400.SendKeys F12Key
AS400.SendKeys F12Key
Case " 42040 "
AS400.SendKeys F3Key
AS400.SendKeys F12Key
AS400.SendKeys F12Key
'Empty
Case " "
If AS400.SearchText("Sign On", 1, 80, reverse) Then
Exception.Flag = True
Exception.ErrMessage = messageMustSignIn
GoTo Cleanup
End If
Select Case AS400.GetText(1, 32, 10)
'Exit
Case " Exi"
AS400.SendKeys EnterKey
'Sign-on Information
Case "ign-on Inf"
AS400.SendKeys EnterKey
AS400.SendKeys EnterKey
'Display Program Messages
Case "lay Progra"
AS400.SendKeys EnterKey
AS400.SendKeys EnterKey
'Display Messages (Standard screen)
Case " Display M"
AS400.SendKeys EnterKey
'Sign On"
Case " Sign O"
Exception.Flag = True
MsgBox "Please sign into the AS/400 before proceeding", _
vbInformation, "Sign-In required"
Exit Do
'MSM screens
Case " "
Exception.Flag = True
MsgBox "Please ensure the AS/400 is signed into the current environment " & _
"before proceeding", vbInformation, "Incorrect AS/400 location"
Exit Do
End Select
Case Else
If AS400.SearchText("Sign On", 1, 80, reverse) Then
Exception.Flag = True
Exception.ErrMessage = messageMustSignIn
GoTo Cleanup
End If
AS400.SendKeys F3Key
AS400.SendKeys F12Key
End Select
i = i + 1
Exception.ErrMessage = " ... ... Failed attempts: " & i
Loop While i <= maxAttempts
Cleanup:
AS400.Pause
Exception.Pop
End Sub
Public Function ConfirmHomeScreen(ByVal AS400 As cAS400, ByRef Exception As cException) As Boolean
'Passes error handling up the call stack
On Error GoTo 0
If Not Exception Is Nothing Then Exception.Push "General.ConfirmHomeScreen"
If Exception.Flag And Exception.ErrMessage = messageMustSignIn Then
ConfirmHomeScreen = False
MsgBox messageMustSignIn, vbCritical, "The AS/400 has signed out of this session"
Else
ConfirmHomeScreen = AS400.SearchText(Trim(tagHome), 1, 1, forward)
End If
Exception.Pop
End Function
Public Function CheckString(ByVal result_to_save As String, Optional ByVal extra_spaces As Integer = 5) As String
Dim lenCount As Integer
lenCount = Len(Trim(result_to_save))
If lenCount >= 1 Then
CheckString = Trim(result_to_save)
Else
CheckString = Space(extra_spaces) & "(Empty)"
End If
End Function
Public Sub ClearEntryField(ByVal AS400 As cAS400, ByVal number_of_spaces As Long, _
ByVal row_to_enter As Long, ByVal col_to_enter)
AS400.SetText Space(number_of_spaces), row_to_enter, col_to_enter
End Sub