販売管理ソフトを作る - 「見積一覧」 フォーカス制御

「見積一覧」 フォーカス制御

■ frmList


00302 '[Enter] による フォーカス制御
00303 Private Sub txtDateMin_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
00304 Call TextKeyDown(KeyCode, Shift)
00305 End Sub
00306 Private Sub txtDateMax_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
00307 Call TextKeyDown(KeyCode, Shift)
00308 End Sub
00309 Private Sub txtBusyo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
00310 Call TextKeyDown(KeyCode, Shift)
00311 End Sub
00312 Private Sub txtTanto_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
00313 Call TextKeyDown(KeyCode, Shift)
00314 End Sub
00315 Private Sub txtTokui_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
00316 Call TextKeyDown(KeyCode, Shift)
00317 End Sub
00318 Private Sub TextKeyDown(ByRef KeyCode As MSForms.ReturnInteger, ByRef Shift As Integer)
00319 '13: vbKeyReturn, 9:vbKeyTab
00320 If (KeyCode <> 13) And (KeyCode <> 9) Then Exit Sub
00321 If ActiveControl Is Nothing Then Exit Sub
00322
00323 Dim intKeyCode%: intKeyCode = KeyCode
00324 Dim intShift%: intShift = Shift
00325 Shift = 0
00326 KeyCode = 0
00327 '
00328 '1:vbShiftMask
00329 If intShift = 0 Then
00330 '入力値が妥当な時だけ、次のコントロールへ移動
00331 If InputCheck(ActiveControl) Then
00332 Call NextControl
00333 End If
00334
00335 ElseIf (intShift And 1) = 1 Then
00336 '前のコントロールへ移動
00337 Call PrevControl
00338 End If
00339 End Sub
00340
00341 '次のコントロールへ移動
00342 Private Sub NextControl()
00343 If ActiveControl Is txtDateMin Then
00344 txtDateMax.SetFocus
00345 TextGotFocus txtDateMax
00346
00347 ElseIf ActiveControl Is txtDateMax Then
00348 txtBusyo.SetFocus
00349 TextGotFocus txtBusyo
00350
00351 ElseIf ActiveControl Is txtBusyo Then
00352 txtTanto.SetFocus
00353 TextGotFocus txtTanto
00354
00355 ElseIf ActiveControl Is txtTanto Then
00356 txtTokui.SetFocus
00357 TextGotFocus txtTokui
00358
00359 ElseIf ActiveControl Is txtTokui Then
00360 cmdSearch.SetFocus
00361 End If
00362 End Sub
00363
00364 '前のコントロールへ移動
00365 Private Sub PrevControl()
00366 If ActiveControl Is txtDateMin Then
00367 cmdSearch.SetFocus
00368
00369 ElseIf ActiveControl Is txtDateMax Then
00370 txtDateMin.SetFocus
00371 TextGotFocus txtDateMin
00372
00373 ElseIf ActiveControl Is txtBusyo Then
00374 txtDateMax.SetFocus
00375 TextGotFocus txtDateMax
00376
00377 ElseIf ActiveControl Is txtTanto Then
00378 txtBusyo.SetFocus
00379 TextGotFocus txtBusyo
00380
00381 ElseIf ActiveControl Is txtTokui Then
00382 txtTanto.SetFocus
00383 TextGotFocus txtTanto
00384 End If
00385 End Sub
00386
00387 'フォーカス取得
00388 Private Sub txtDateMin_GotFocus()
00389 TextGotFocus txtDateMin
00390 End Sub
00391 Private Sub txtDateMax_GotFocus()
00392 TextGotFocus txtDateMax
00393 End Sub
00394 Private Sub txtBusyo_GotFocus()
00395 TextGotFocus txtBusyo
00396 End Sub
00397 Private Sub txtTanto_GotFocus()
00398 TextGotFocus txtTanto
00399 End Sub
00400 Private Sub txtTokui_GotFocus()
00401 TextGotFocus txtTokui
00402 End Sub
00403 Private Sub TextGotFocus(txtArg As MSForms.TextBox)
00404 txtArg.SelStart = 0
00405 txtArg.SelLength = txtArg.TextLength
00406 End Sub