powered by simpleCommunicator - 2.0.55     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / мне нужно при нажатии определенную кнопку выполнялось запрос
10 сообщений из 10, страница 1 из 1
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36975977
shoh
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
мне нужно при нажатии определенную кнопку выполнялось запрос
Например: как кнопка F1, т.е. при нажатии кнопку F1 открывалось окно "помощь"

спасибо за помощь
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36976025
Фотография Antonariy
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Событие KeyDown.
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36976649
shoh
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Antonariy,

а как использовать и где можно найти код клавиш(кнопок)
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36976670
Фотография Shocker.Pro
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
shohAntonariy,

а как использовать и где можно найти код клавиш(кнопок)

в хелпе по этому событию

для F1 - vbKeyF1
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36976864
shoh
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Shocker.Pro,

у меня в хелпе не показывает, либо из-за версии ПО или не польный пакет установлен
Прошу дать синтаксис и если есть/можно пример дать.
мне нужно, что бы через клавиатуры нажимая определенные кнопки можно было выполнять какие то действие
(как в word, excel)
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36976916
Фотография HandKot
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
авторСобытие KeyDown.

а почему не использовать встроенный функционал офиса
Макросы - япараметры - Сочетание клавиш ?
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36976993
Фотография Shocker.Pro
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
shohу меня в хелпе не показывает, либо из-за версии ПО или не польный пакет установлен
зато есть msdn
что ж теперь, весь хелп вам сюда постить?

KeyDown, KeyUp Events
Occur when the user presses (KeyDown) or releases (KeyUp) a key while an object has thefocus. (To interpretANSI characters, use the KeyPress event.)

Syntax

Private Sub Form_KeyDown(keycode As Integer, shift As Integer)

Private Sub object_KeyDown([index As Integer,]keycode As Integer, shift As Integer)

Private Sub Form_KeyUp(keycode As Integer, shift As Integer)

Private Sub object_KeyUp([index As Integer,]keycode As Integer, shift As Integer)

The KeyDown and KeyUp event syntaxes have these parts:

Part Description
object Anobject expression that evaluates to an object in the Applies To list.
index An integer that uniquely identifies a control if it's in acontrol array.
keycode A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the constants in the Visual Basic (VB)object library in theObject Browser.
shift An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of shift is 6.


Remarks

For both events, the object with the focus receives all keystrokes. A form can have the focus only if it has no visible and enabled controls. Although the KeyDown and KeyUp events can apply to most keys, they're most often used for:

Extended character keys such asfunction keys.


Navigation keys.


Combinations of keys with standard keyboard modifiers.


Distinguishing between the numeric keypad and regular number keys.
Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key.

KeyDown and KeyUp aren't invoked for:

The ENTER key if the form has a CommandButton control with the Default property set to True.


The ESC key if the form has a CommandButton control with the Cancel property set to True.


The TAB key.
KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: keycode, which indicates the physical key (thus returning A and a as the same key) and shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the shift argument, you can use the shift constants which define the bits within the argument. The constants have the following values:

Constant Value Description
vbShiftMask 1 SHIFT key bit mask.
VbCtrlMask 2 CTRL key bit mask.
VbAltMask 4 ALT key bit mask.


The constants act asbit masks that you can use to test for any combination of keys.

You test for a condition by first assigning each result to a temporary integer variable and then comparing shift to a bit mask. Use the And operator with the shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, as in this example:

ShiftDown = (Shift And vbShiftMask) > 0

In a procedure, you can test for any combination of conditions, as in this example:

If ShiftDown And CtrlDown Then

Note If the KeyPreview property is set to True, a form receives these events before controls on the form receive the events. Use the KeyPreview property to create global keyboard-handling routines.


KeyDown, KeyUp Events ExampleThis example demonstrates a generic keyboard handler that responds to the F2 key and to all the associated ALT, SHIFT, and CTRL key combinations. The key constants are listed in the Visual Basic (VB) object library in the Object Browser. To try this example, paste the code into the Declarations section of a form that contains a TextBox control, and then press F5 and press F2 with various combinations of the ALT, SHIFT, and CTRL keys.

Private Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)
Dim ShiftDown, AltDown, CtrlDown, Txt
ShiftDown = (Shift And vbShiftMask) > 0
AltDown = (Shift And vbAltMask) > 0
CtrlDown = (Shift And vbCtrlMask) > 0
If KeyCode = vbKeyF2 Then ' Display key combinations.
If ShiftDown And CtrlDown And AltDown Then
Txt = "SHIFT+CTRL+ALT+F2."
ElseIf ShiftDown And AltDown Then
Txt = "SHIFT+ALT+F2."
ElseIf ShiftDown And CtrlDown Then
Txt = "SHIFT+CTRL+F2."
ElseIf CtrlDown And AltDown Then
Txt = "CTRL+ALT+F2."
ElseIf ShiftDown Then
Txt = "SHIFT+F2."
ElseIf CtrlDown Then
Txt = "CTRL+F2."
ElseIf AltDown Then
Txt = "ALT+F2."
ElseIf SHIFT = 0 Then
Txt = "F2."
End If
Text1.Text = "You pressed " & Txt
End If
End Sub
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36977637
Ципихович Эндрю
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
shoh, вариант
Application.Run "Normal.Модуль_ЦЭ.Макрос_ЦЭ"
по этому скрипту Вам придётся в Нормал.дот заиметь модуль "ЦЭ" и макрос "ЦЭ"
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36979020
shoh
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Shocker.Pro,

ВСЕМ ОГРОМНОЕ СПАСИБО , отдельное спасибо Shocker.Pro
...
Рейтинг: 0 / 0
мне нужно при нажатии определенную кнопку выполнялось запрос
    #36979471
Ципихович Эндрю
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
shoh, ушёл по английски???
...
Рейтинг: 0 / 0
10 сообщений из 10, страница 1 из 1
Форумы / Visual Basic [игнор отключен] [закрыт для гостей] / мне нужно при нажатии определенную кнопку выполнялось запрос
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]