Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 06-24-2009, 05:39 AM   #1
Baseband Member
 
Join Date: Sep 2008
Posts: 60
Default VB and Delphi help

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
__________________

__________________
SAY NO TO PIRACY
Feras is offline   Reply With Quote
Old 06-24-2009, 05:48 PM   #2
Baseband Member
 
Join Date: Jun 2009
Posts: 36
Default Re: VB and Delphi help

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
__________________

dmarciano is offline   Reply With Quote
Old 06-25-2009, 04:05 AM   #3
Baseband Member
 
Join Date: Sep 2008
Posts: 60
Default Re: VB and Delphi help

Hello M.r dmarciano

that was an excellent explanation

Thanks alot
__________________
SAY NO TO PIRACY
Feras is offline   Reply With Quote
Old 06-28-2009, 08:39 PM   #4
Baseband Member
 
Join Date: Jun 2009
Posts: 36
Default Re: VB and Delphi help

Np
dmarciano is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 11:12 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0