VB 윈도우7에서 Sendkey 사용하기
페이지 정보
작성자
본문
준비사항 : Form1, Text1, Text2, Text3, Text4
Option Explicit
Dim WshShell As Object
Private Sub Form_Load()
Set WshShell = CreateObject("WScript.Shell")
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set WshShell = Nothing
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
WshShell.SendKeys "{Tab}"
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
WshShell.SendKeys "{Tab}"
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
WshShell.SendKeys "{Tab}"
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
WshShell.SendKeys "{Tab}"
End If
End Sub
///////////////////////// 다른방법 : API사용 /////////////////////////
Option Explicit
Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hwnd
As Long) As Long
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Putfocus Text2.hwnd
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Putfocus Text3.hwnd
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Putfocus Text4.hwnd
End If
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
KeyAscii = 0
Putfocus Text1.hwnd
End If
End Sub
댓글목록
등록된 댓글이 없습니다.