Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Api Code For Event On Keydown Or Keyup In Vba


Months ago I found API code which would permit you to choose a key and choose to run a macro on either pressing that key down or on the release of the key ( key up)

It also worked for the mouse buttons.

I copied and tested it in excel .

This code was not for use only on form you could fire a macro with a key down or key up from a worksheet if you wanted to

But I have misplaced the code and now cannot find it searching the internet

Does anyone have this or equilavent code ?

Thank you for your help




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Keydown And Keyup Event Problem
Hi
I am facing a strange problem in vb6. I made a program in which I have used keyup and keydown events. The keydown event is sending some messeges to com2 which I activated by API. Also the keyup sends some messege to com2. My problem is that under XP within vb6 IDE it is working perfectly but when I am compiling it and trying to run the exe the keydown is working but keyup isnot working at all. Can anybody help what is the problem. I have used the same code in 98 and 2000. It works there but in Win XP it isnot working. And also I wanted to know another thing. If I use mscomm control then it takes over both of the comm ports. Thats why I had to use api. Because for one comm port I have to communicate one device through a dll provided by the manufacturer. So when I used mscomm for the above mentioned task the dll wasnot finding any ports. Is there any way to use mscomm and the dll at the same time. As I am a new programmer i am really confused what is the error. Any suggession will be highly helpful.

Sangit

KeyUp Event Also Fires In KeyDown, That's Not Right ...?
I noticed that when I hit the arrow down, it also checks for arrow up.

Code:

Private Sub text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
    
      Debug.Print "KeyDown"
   
End Sub


Private Sub text1_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
    
      Debug.Print "KeyUp"
   
End Sub



Try it and you will see KeyUp and Keydown in the debug window regardless if you hit the up or down arrow.
I caught the KeyCode so I can still distinguish, but I would expect the up and down event to fire whenever the appropriate key is pressed.

Is that normal ?

thankls,

robert




Edited by - eurob on 6/9/2005 2:00:15 PM

Can Someone Help Me On KeyUp,KeyDown And KeyPress Event.
Can someone can tell me how to create a function to Capture a KeyUp,KeyDown and KeyPress event?

I know that in the Main form there is a KeyUp,KeyDown and KeyPress Event i wanted to know if there is a way to create another KeyUp,KeyDown and KeyPress event even though the main form is not focused. I have a program with an ActiveX that we are testing but it is the main focus of the Form therefore when it is active the KeyUp,Keydown and KeyPress of the main form does not happen because the form is not active,i wanted to know if i can create a function that can get this Events even though the main form is not the active one.

Hope someone understands my question.

Thanks in advance!

Keydown And Keyup Event Problem
Hi
I am facing a strange problem in vb6. I made a program in which I have used keyup and keydown events. The keydown event is sending some messeges to com2 which I activated by API. Also the keyup sends some messege to com2. My problem is that under XP within vb6 IDE it is working perfectly but when I am compiling it and trying to run the exe the keydown is working but keyup isnot working at all under XP. Can anybody help what is the problem. I have used the same code in 98 and 2000. It works there but in Win XP it isnot working. And also I wanted to know another thing. If I use mscomm control then it takes over both of the comm ports. Thats why I had to use api. Because for one comm port I have to communicate one device through a dll provided by the manufacturer. So when I used mscomm for the above mentioned task the dll wasnot finding any ports. Is there any way to use mscomm and the dll at the same time. As I am a new programmer i am really confused what is the error. Any suggession will be highly helpful.

Sangit

KeyUp / KeyDown
VB Code:
If vbKeyF12.KeyDown = True ThenMsgBox "You pressed F12"ElseIf vbKey12.KeyUp = True ThenMsgBox "You took your finger off F12" ' <-- lol ...... =/End IfEnd If

I know that's wrong but hopefully you get what I am trying to do. How is it done properly?

I Need Help With KeyDown And KeyUp
I will say right now, I am somewhat of a noob. Well, more then somewhat I supose but anyway. My problem is with the KeyDown and KeyUp function. I an image move with using the aarows. I have no idea what the code I need is, but I do know it can be done. Someone please help.

Flexgrid KeyUp/KeyDown
Is there a trick to using the Up/Down arrows for scrolling in a msflexgrid keyup/keydown/keypress event. I can't even get the event to trigger when using any of the arrows.

I tried setting the forms keypreview to true but that doesn't work either.

Any help would be appreciated.

KeyPress KeyDown KeyUp
I've been trying to make my program react to keypress (obviously), i've checked and rechecked the script and I've just come to the conclusion that it's hopeless but then I decided I should leave that up to you. I have sorta what it looks like down here...

... picture1_keypress(...)

if ascii = vbKeyNumpad9 then
...
elseif ...
...
end if

You get the jist, if you need something more detailed than that, I Guess i could post the actuall script. I put watches on a variable changed during the first If then statement but it didn't break (thus, it didn't change ) I then made it so that ANY button pressed would break it (I think... ) and nothing. Im working with VB 6.0 (Is that new? I'm so outa date these days) and tried EVERYTHING i could think of. Ne1 there to help me?

KeyUp,KeyDown In 2 Player
I am making a game with two paddles, kind of like pong. It uses key up and key down and has two players.... I have a problem though. The keys get messed up say when player 1 presses and holds a key and player 2 trys to press another key (which would symbolize up or down) heres my code.... i just want to have it so that the keys dont get messed up when player one wants to go up/down at the same time player 2 wants to get up/down etc.


Code:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 65 Then ' Detects if player 1 went up
P1up = True
End If
If KeyCode = 90 Then ' Detects if player 1 went down
P1down = True
End If

If KeyCode = 222 Then ' now with player 2
P2up = True
End If
If KeyCode = 191 Then ' same with player 2
P2down = True
End If

End Sub

Code:

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)

' If player lets go of button, then bar stops moving
If P1up = True Or P1down = True Then
P1up = False
P1down = False
End If

If P2up = True Or P2down = True Then
P2up = False
P2down = False
End If

End Sub

Send KeyDown And KeyUp
Hey. I was wondering if there was any way to tell a program other than itself that a key is pressed or that a key is released. For example, telling notepad that the 'a' key is pressed. If there is could someone post a quick example of how to use it or somewhere where I could learn how to use it. Thanks!

Keydown - Keyup Problem
in my program, when i press a command button, i want my program to break from a loop and deal with the action called and then return to the loop

it is breaking from the loop, so that isn't a problem.( and returning)

however, it isn't dealing with the command properly.
the command involves determing how long the key has been pressed down for, using the "Keyup and Keydown" commands, and doing a different action corresponding to the length of time the button is pressed.

I've figured out that the Timer function is called on Keydown correctly, but on Keyup it doesn't return anything!!

I'm reallly confused as to why this is?? Does anybody know??is it because i have paused the loop??

KeyDown, KeyPress Or KeyUp!
I am using the WebBrowser control. When a user visits a web page, I want to first find out whether the web page has a TextArea HTML Form element or not. I know how to do this.

My intention is when the user starts typing text in a TextArea, I want to save whatever he is typing in the TextArea in a text file. I would like to incorporate this using the KeyDown or KeyPress or KeyUp events i.e. as soon as the users types a letter in the TextArea, that letter should be saved in the text file. When he types the next letter, that letter (along with the already saved letter) should again be saved in the text file.

So suppose a user types I am a VB newbie, the text file should be written with I am a VB newbie. This is how I tried to catch the event:
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)    On Error Resume Next    Dim x    Dim HTMLForm As HTMLFormElement    Dim HTMLFormElement As HTMLInputElement    Dim HTMLTextArea As HTMLTextAreaElement    Set HTMLForm = wWeb.Document.Forms(0)    For x = 0 To HTMLForm.elements.Length        If (TypeOf HTMLForm.Item(x) Is HTMLInputElement) Then            Set HTMLFormElement = HTMLForm.Item(x)            If (HTMLFormElement.Type = HTMLTextArea) Then                MsgBox "hello" 'this is where I will populate the text file            End If            'Debug.Print HTMLFormElement.Name & ": " & HTMLFormElement.Type        End If    NextEnd Sub
But what this does is even if a user types something in a HTML TextBox element, then also the MsgBox gets activated. I want the MsgBox to activate only & only when the user types something in a TextArea & not in any other HTML Form element. How do I accomplish this?

Also should I use the KeyDown or KeyPress or KeyUp event to implement this?

As an aside, if anyone is inquisitive to know why I want this feature in my browser, this is because sometimes I have experienced that while typing something in a TextArea, there will be a sudden power failiure due to which when the power is restored, I have to type the entire text again in the TextArea. I don't want my clients to experience this. So even if there is a sudden power failure, my users can just copy whatever text they had typed before the power failure from the text file & paste it in the TextArea when the power gets restored & continue with their typing

Thanks,

Arpan

Disable KeyUP &amp; KeyDown
Hi There,
I want to disable Key Up & Key Down Keys of a MSHFlex Grid.
the Leave Cell event is fired if these keys r pressed . I want to avoid that..

Thankz in advance for ur help....

Problem With The KeyDown Or KeyUp
I use the F keys like hot keys using the Form event KeyDown or KeyUp, it works very well but I don't understand why sometimes when I press one my program crashes without showing me any Run time error. Is this normal or I'm doing something wrong ?

KeyPress / KeyUp / KeyDown
I am removing most of the Buttons from my form and replacing them with F(this) and F(that)
What _press event is best

Thom

Capture Keyup, Without Keyup Event?
I have a form that runs in the background, and controls another program (winamp), on certain Keypress. It uses a Global hook, that works Without having the form have the focus. the problem is, If i hold down like "Ctrl" + "N" (which I have bound to go to Next song), It Calls up next song Over and over again... So, If the user just wants to go to the next song, they would have to press it as fast as they can (which would be pretty stupid). So, I need a simple line that captures keyup (and it cant be a select case, or a Keyup event). Can I have some help? Thanks!

Beep When Keydown, Stop When Keyup
Hey all,
I'm trying to make a morse code app that beeps when you press a key anywhere in the app and stops beeping when you release the key.

I've been doing some searching through the forums and I keep finding a reference to the beep api. There's two problems with that. 1) it won't be recordable, and 2) you can't start it at one point and stop it at an unknown interval later. I found some references to starting a stopping the playing of mp3 or wav files, but that was for say, a three minute song and start/stop buttons. I can't think of any viable way to do this. Maybe using the mciSendString API, but then there would need to be some way to specify and tone and not a file. If anyone's got any ideas that would be awesome. Thanks.

Arrow Keydown And Keyup Events
i know this is a noob question but how do i get my program to do something when the up arrow keydown or when the left arrow keydown or when an arrow keyup and so on

Keypress/Keydown/Keyup Events
Hi again, I know this is probably very trivial, but I just can't figure it out! How do you hook keyboard events?? I am trying to hook a keydown, keyup sequence (similar to the way I am already using mousedown and mouseup), but it just doesn't catch keypresses? I set up a keydown event for the form, and have it change the form caption to the keycode, and when I press a key, nothing happens. Now there is other stuff on the form (buttons, labels, frames, etc), is this screwing it up? Do I need to use API to have it register a keypress as long as this form is open? Is the API way easy (I have very little experience with API)? Also, is there a place I can find a list of all the Keycodes and KeyASCIIs? Thanks for any help, this is very frustrating!

Update: Sorry, I just now thought to open a new project with no buttons or anything, just a blank form, and try the key down. It now works. The question still remains, how can I have a keypress work for the entire form, regardless of the buttons, frames, labels, checkboxes, web browsers, etc? Is API my only option?

Treeview Keydown/ Keyup Events
Hi,

i am trying to capture key down events from a treeview control under VBA in MS Excel.

When i add the following private sub i always get an error, though it works fine for TextBox controls.

I dont understand that since the KeyUp and KeyDown events are listed in the Object reference for the treeview control.

Private Sub TreeView1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

thanks

ch

Capture/trap Keydown And Keyup Without Focus?
I'm looking to write a prog that allows me to software remap my keyboard for things like dvorak or single key macros. I want a formless (hidden form) sys tray control to be the main portion...

...I recently came upon the idea of triggering things by timed holding of single keys (e.g. hold N for 2 seconds to type boilerplateText1), hence I need both keydown and keyup control.

How can I register and trap both keydown and keyup seperately without giving my program focus??

can I then use sendkeys to enter my boilerplate text?

URGENT!!! How Can I Ignore KeyUp And KeyDown In A Textfield?
Hi,

I have a textfield which activate a ListBox to compare inputs. When the user press the key up or down I move in the ListBox, even I am still with the cursor in the textfield. But the problem is that the cursor in the textfield moves too. How can i block this?


nice greetings
Franky

Rich Text Box Coloring Without Keydown Keyup
Im trying to work on a IRC client and I want specific keywords to have a seperate color from the rest of the text, but the issue i am having is that these keywords arent being typed in, they are appearing from the server, So the keydown and keyup function doesnt really work, Does anyone have an example of how I would colorize the word ermm example "Connection" to say red? I have searched the forums repeatively for this and also pscode but I am coming up empty handed.

KeyUp Event
I was having problems with the Shift + Tab keys working in my KeyUp Event. I realized that when I am in cmbModelNo and hit enter or tab the KeyUp event does not get called. When the code is in the KeyDown event is does get called. Why is this?


Code:
If KeyCode = vbKeyReturn
If Trim(cmbLIModelNo(Index).Text) <> "" Then
If KeyCode = 13 Then
'Set this flag to true so the click event will be processed.
fgKeyReturn = True
End If
Call cmbLIModelNo_Click(Index)
End If
End If

No Keyup Event
I have a form and in the forms keyup event I display another form is the key pressed is F2.
All works well, until I add my usercontrol to the form and then the keyup event no longer fires.
Has anyone seen this type of thing before?

KeyUp Event
In my VBA Excel application, I want to call a procedure when the user presses Ctrl-l. I know I have to do something like that but I don't know exactly how does it works.

private Sub oXLApp_KeyUp(byval KeyAscii as MSForms.ReturnInteger, byval Shift as Integer)
'MsgBox (KeyAscii & Shift)
End Sub




Could you please help me.

Thanks

Getting 'KeyUP' Event From Other Applications.
Hello,

I would like to trigger an event in an application when the user releases a key. I want the trigger to happen, even if they do not currently have the application in focus.

I have no idea how this may be acheived, and have done a quick search of the forum already.

Many thanks,



/Sib
Thar ain't nuttin a good can o' raid won't fix!

Webbrowser Control/Keyup Event
Hi,
I'm trying to disable the CTRL-N function from the webbrowser control I have on a form. I tried using the KeyUp/KeyDown/KeyPress events but they dont work when the webbrowser control has the focus.

Any ideas how I can disable this functionality?

Thanks

KeyUp Event And Label Captions
I am writing a mathematics program. In a "testing" mode, a multiplication problem pops up on the screen and waits for a user to answer the question. My problem is getting the answer from the keyboard to the screen.

I want to use a KeyUp event so that when the first number of the answer is typed it changes the caption of lblAns1 to the digit pushed. When the second digit has been input, I want that to go in lblAns2. I keep running into the problem of it always putting the number in lblAns2 and can't get it to change anything on lblAns1.

I don't want to use a text box because A) I don't want the blinking cursor and B) I have it set up on the screen with 4pix by 4pix boxes for these answers, it would not look right with a text box.

Any ideas/code on how to help me would be GREATLY appreciated. Thanks!

KeyUp Event Problem With Keyfunction
i enabled the keypreview of the form
then I use this code

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF9
Debug.Print "f9"
Case vbKeyF10
Debug.Print "f10"
End Select
End Sub

and sometimes (I can't find exactly when and why) I press the F10 and after the F9 and the form is "locked up" the flashing little bar in a textbox stop flashing until i press another key and then I can continue to press F9 or F10.. somebody know why ?
There's not any shortcut i set with those keys on my system.
Somebody have a clue with this ?
If I use vbkey1 adn vbkey2 there's not this problem.

KeyUp Event Does Not Work With MSFlexGrid
Somebody knows why The KeyUp, KeyPress and KeyDown event are not called when you press any key on a MSFlexGrid ?
Thanx !

Automatic Tabbing In Keyup Event
I have two text boxes - txtbox1 whose text length should be 3, txtbox2 whose textlength should be 2. I want the mouse cursor position to tab automatically as soon as the user enters the last character in txtbox1. I have written the following code in keyup event to accomplish this.

Private Sub txtbox1_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(txtbox1.Text) = 3 Then
txtbox2.SetFocus
End If
End Sub


But the problem is, if the user hits SHIFT+TAB to return to txtbox1 from txtbox2, the mouse cursor comes back to txtbox2 because the keyup event fires again. Is there a way to prevent this, so that if the user hits SHIFT+TAB the focus stays on txtbox1 only? Please help.

Using Combinations SHIT + CTRL + ALT + KEY On KeyUp Event
HELP - HELP - HELP

Hi, I'm trying to use the KeyUp event to control the combination use SHIFT + CTRL + ALT + KEY or simillar combination.

I'm using the following code.

Private Sub productcode_KeyUp(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
   ' Display key combinations.
   If ShiftDown And CtrlDown And AltDown Then
      Txt = "SHIFT+CTRL+ALT+" & KeyCode
   ElseIf ShiftDown And AltDown Then
      Txt = "SHIFT+ALT+" & KeyCode
   ElseIf ShiftDown And CtrlDown Then
      Txt = "SHIFT+CTRL+" & KeyCode
   ElseIf CtrlDown And AltDown Then
      Txt = "CTRL+ALT+" & KeyCode
   ElseIf ShiftDown Then
      Txt = "SHIFT+" & KeyCode
   ElseIf CtrlDown Then
   Txt = "CTRL+" & KeyCode
   ElseIf AltDown Then
      Txt = "ALT+" & KeyCode
   ElseIf Shift = 0 Then
      Txt = KeyCode
   End If
   Debug.Print "You pressed " & Txt
   KeyCode = 0
    
end SUB.


If I press SHIFT + CRTL + ALT + A I will have the following result on inmediate screen.

You pressed SHIFT+CTRL+ALT+65
You pressed CTRL+ALT+16
You pressed CTRL+18
You pressed 17


But I Need only the Fisrt Line (You pressed SHIFT+CTRL+ALT+65) The event was triggered 4 times one per key. I need get only the firts one and stop the proccess.



HELP - HELP - HELP

Problem With Checking Text Using KeyUp Event
I have a series of TextBoxes with a Label next to each one. On the KeyUp event a check is performed to see if the values in each textbox is different to each corresponding label. I have it such that I can Tab through each textbox and the text is automatically highlight. This makes it fast and easy to change the data in the textboxes but also cause a problem triggering the KeyUp event if I tab and enter data too fast. Is there a way around this without having to slow down my data entering?



Edited by - drkclw on 2/27/2004 8:07:32 AM

Keydown Event
Hi,

Looking for a bit of advice, I am currently developing an Online RPG. With client software linking to the server software through winsock.

I am currently having problems with the keydown event.

The function is this.
When the keydown event is called, it checks to see if the assigned keys are pressed for each function. If they are it moves the character....however...

If the keys are pressed and kept down, it does nothing until the keys are released. Is there any way to process the function so that it displays it every millisecond, for example. Instead of having to release the key to process it?

Code:


Code:
Private Sub picMain_keydown(keycode As Integer, shift As Integer)
If keycode = 37 Then
globalxpos = globalxpos - 1.2
If globalxpos = -48 Then
globalxpos = 0
globala = globala + 1
End If
Call render
Exit Sub
End If
If keycode = 38 Then
globalypos = globalypos - 1.2
If globalypos = -48 Then
globalypos = 0
globalb = globalb + 1
End If
Call render
Exit Sub
End If
If keycode = 39 Then
globalxpos = globalxpos + 1.2
If globalxpos = 48 Then
globalxpos = 0
globala = globala - 1
End If
Call render
Exit Sub
End If
If keycode = 40 Then
globalypos = globalypos + 1.2
If globalypos = 48 Then
globalypos = 0
globalb = globalb - 1
End If
Call render
Exit Sub
End If
End Sub
Many thanks

Ross

KeyDown Event
Im having problems being able to move around a grid of txt boxes using the keyboard rather than have to click on each txt box. ive included the .frm and if you run it, u'll see that you can move around slightly but it jumps about the grid, not sure what the prob is

thanks guys

Dave

Keydown Event
I'm usig the keydown event to move from cell to cell in a flexgrid. My code works great but I get a bell tone on every move. Can anyone tell me what I am doing or not doing?

Thanks in Advance


Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print KeyCode, Shift

'Move forward in spreadsheet
If ((KeyCode = 13 Or KeyCode = 9) And Shift = 0) Then 'Enter Key is Character 13 Tab key is 9

FG_Part_Dev.Text = Text1.Text
SRow = FG_Part_Dev.RowSel
SCol = FG_Part_Dev.Col + 1

If SCol = FG_Part_Dev.Cols Then 'Move focus to next column
SCol = 1
SRow = SRow + 1
If SRow = FG_Part_Dev.Rows Then SRow = 1

End If

FG_Part_Dev.Text = Text1.Text
Text1.Visible = False

FG_Part_Dev.RowSel = SRow
FG_Part_Dev.ColSel = SCol
FG_Part_Dev.Row = SRow
FG_Part_Dev.Col = SCol

KeyCode = 0
Shift = 0
End If

'Move backward in spreadsheet
If (KeyCode = 9 And Shift = 1) Then 'Tab key is keyCode is 9 Shift =1 indicates the shift button is held down

'FG_Part_Dev.Text = Text1.Text
SRow = FG_Part_Dev.RowSel
SCol = FG_Part_Dev.Col - 1

If SCol = 0 Then 'Move focus to next column
SCol = FG_Part_Dev.Cols - 1
SRow = SRow - 1
If SRow = 0 Then SRow = 1

End If

'FG_Part_Dev.Text = Text1.Text
'Text1.Visible = False

FG_Part_Dev.RowSel = SRow
FG_Part_Dev.ColSel = SCol
FG_Part_Dev.Row = SRow
FG_Part_Dev.Col = SCol

' KeyCode = 0

End If
End Sub

Lag On The Keydown Event
this is probably well known, and there has to be a way around this..

but this code right here:


Code:
Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyRight Then
Picture1.Left = Picture1.Left + 50
End If
End Sub

one would think it would be flawless, but no,... when you hold the arrow key, the picture box moves 50 pixels (or whatver) to the right, stops, and then continues moving..

this is kinda annoying.. is there a way of making a "smooth" movement?

KeyDown Event
Is it possible to execute only one line of code per key down? This is my code:
Code:
Case vbKeyDown

If Stage1 = True Then Stage2 = True
If Stage2 = True Then Stage3 = True

Stage1 = True


End If

I am trying to switch between 3 things when pressing the down key, It works the first time, but the second time I press the key both stages 2 AND 3 are set to True because VB goes on and reads all the code.I need to set ONE stage at a time. So is there a way to make it only read one line of code per keypress?

Thanks, I hope that makes sense.

Keydown Event
i wont to be able to enter some numbers into a textbox then be abe to press enter, and it then runs some code to search a database.
i know how to search the database but using the key down event i enter any number and it courses an error i only wont it to actevate the search code when i press enter. am gessing that an if statment is needed but need help with geting it work with the enter key.
any help is good help!
thanx

KeyDown Event
Hi, VB people

I have a form with several controls and a PictureBox. I want to use the KeyDown event on the PictureBox, but I have another active form (Form2). When the Form2 gets the focus and it's returned to Form1, the KeyDown event doesn't work. I set th TabStop properties of the rest of the controls but it doesn't work.

Can I program a general KeyDown event in the form? What can I do???


Thanx anyway.
CHARLIE.

KeyDown Event
I have a text box. If the text box has text entered previously then I want to discourage the use of the BACKSPACE and ARROW keys thereby preventing the previously entered text from being deleted. New text is OK. It seems to work fine with the arrow keys but not for the BACKSPACE key. The following is my code.
Help.

Private Sub txtComment_KeyDown(KeyCode As Integer, Shift As Integer)
dim strLen as String
dim blnInsert as Boolean
strLen = Len(txtComment.text)

Select Case KeyCode
Case 8
If strLen > 0 Then
'SendKeys "(^Z)"
KeyCode =0
End If
Case 37, 38, 39, 40
If strLen > 0 Then
KeyCode = 0
End If
Case Else
If Not blnInsert Then
If txtComment.Text = "" Then
'txtComment.Text = CStr(Now()) & " Modified By "
Else
txtComment.Text = txtComment.Text & vbCrLf & CStr(Now()) & " Modified By "
End If
txtComment.SelStart = Len(txtComment.Text)
blnInsert = True
End If
End Select

End Sub

Using The KeyDown Event
I was wondering if you can check the keycode value from anywhere on the form and only have the code in one procedure.

Jeff

KeyDown Event
I would like to intercept a KeyDown event in a Form in my application. I have put in the following code:


Code:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = vbCtrlMask Then
If KeyCode = vbKey1 Then
' do something here
End If
End If
End Sub



When I run the application, this method is never invoked when I strike a key on the keyboard.

Help

Thanks,

Judy

KeyDown Event Help
Hi
I want to only allow a text box to accept numeric characters and one decimal, with two places to the right. For example

900.50

This is used for entering in a cash amount. I can't figure how to accomodate this in the keydown event. thank you

On Keydown Event?
how would i make it so if i pressed
F then O the O the B then A then R on the form, it would give me a msgbox or somthing?

not all the letter at the same time, but one after the other in order....?

KeyDown Event
Hi, I am writing a program using the keydown event. It works great except I can not get it to send the number keys and other keys like, space, enter, shift, etc. to my text file? Why, would it send letters and not numbers. An example of my code follows:

Code:

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

If keycode = 54 Then
Dim ggFile As Integer
ggFile = FreeFile
Open "C:Log.txt" For Append As ggFile
Print #ggFile, "6";
Close ggFile
End If

Also, When I make the program Invisible it will not send any keys to the file.
Thanks,

Kevin

Edited by kevdog on 02-27-2000 at 02:02 AM

Keydown Event
Hello all,

The problem I am having is with KeyDown event.

1- If I put a text box on a standard form and hit the "Tab" key the keycode returned is 9. But if I put the text box on a usercontrol itting the tab key will not fire the keydown event. Any clues???

Please let me know if I could deal with it in the same way if I have it on a form.

Thank you so much in advance!!!!!

Keydown Event
hi guys

i am developing a car game (top view) in vb6.0.......my problem is with the keydown event....when i keep the up key pressed to accelerate, and we press the left key to go left, then when we leave the left key (with the up key still pressed), the keydown event is lost and we have to repress the up key to move ahead.......

i think multithreading is required to solve this problem........please, if anyone can help me out.......please write back immediately or email me at tushi100@hotmail.com

thanx guys.....
bye

Copyright 2005-08 www.BigResource.com, All rights reserved