Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with my code 1

Status
Not open for further replies.

LordMeka

Instructor
Aug 4, 2006
29
RO
Can someone please help me with my problem

i have a Button on a Form when clicked it sends a value to a TextBox

Ex:
Code:
Private Sub Number3_Click()
If LastInput <> "NUMS" Then
        ReadOut = Format(0, ".")
        DecimalFlag = False
    End If
    If DecimalFlag Then
        ReadOut = ReadOut + Number3().Caption
    Else
        ReadOut = Left(ReadOut, InStr(ReadOut, Format(0, ".")) - 1) + Number3().Caption + Format(0, ".")
    End If
    If LastInput = "NEG" Then ReadOut = "-" & ReadOut
    LastInput = "NUMS"
End Sub
How can i make my code so that it dose the same thing when i press the Keyboard key number 3?

I am a Corel Fan!atic. (NAH)
 

I assume Number3 is a command button (consider renaming it to btnNumber3 or cmdNumber3).

What is LastInput? A text box (txtLastInput)? a Variable (strLastInput)? The same goes for ReadOut.

I guess DecimalFlag is a Boolean (blnDecimalFlag)?

It would be helpfull if you would state what you have and what you are trying to accomplish. You have a click of a command button. What do you mean by "it dose the same thing when i press the Keyboard key number 3? " Press 3 where? As an input into a text box?



Have fun.

---- Andy
 
Number3 Is a comand Button
Last Input its a Var
Read Out is a TxtBox

The code its not important.

I want something like in this example:

I have a button called "BtnOk" and i want to be able to click on it and in the same time if i want to press Enter to have the same thing as if i click on it.

I hope i made my self clear enough


I am a Corel Fan!atic. (NAH)
 
 http://img147.imageshack.us/my.php?image=inputkz8.jpg
I didnt used Hungarian Notation on my code

I am a Corel Fan!atic. (NAH)
 
The code its not important.
Well, your subject says: I need help with my code - you decide, it IS or it IS NOT important :)

It is nice, and helpful, to know what you are looking at...

And now you are changing your requirement: you want to hit Enter and you want to go thru Click event of that button.

(You don't want any more the same thing when i press the Keyboard key number 3)

Set button's Default property to True


Have fun.

---- Andy
 
Look at the KeyDown event for the object.

Code:
 If KeyCode = vbKey3 Then
    MsgBox "3 pressed"
 End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top