VB and Delphi help

Feras

Baseband Member
Messages
60
Hello everybody :)

I am just a starter in programming

I have a code here, I think it is vb code


Code:
Private Sub Form_KeyDown(KeyCode As Integer , Shift As Integer)
If KeyCode = vbKeyF Then End
End Sub

1. What does this code do?
2. Please give me a code does the same work in delphi

Thank you
 
I can't translate this to Delphi (since I don't know it) but I'll tell you what it does.

Code:
Private Sub Form_KeyDown(KeyCode As Integer , Shift As Integer)
This is a subroutine (hence the 'Private Sub' and not 'Private Function') that is called when the form has focus and a key is pressed
Code:
If KeyCode = vbKeyF Then End
KeyCode is passed as an argument. This statement is seeing if the 'F' key is pressed. The reason for the 'vbKeyF' is you will notice in the function that the 'KeyCode' is passed as an integer; actually the ASCII decimal code. So instead of trying to remember all the ASCII codes VB has the programmed in for the most part. This code really does do anything in the sense that if the 'F' key is pressed then it just ends, or if any key is pressed. It would probably make more sense if it was:

Code:
If KeyCode = vbKeyF then DoFunction1() else DoFunction2() EndIf

The last part is just the standard ending for subroutine:
Code:
End Sub
 
Back
Top Bottom