473,421 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

How do i bind a key?

Well, How do i bind a key in Vb6.0? and, i have searched.
Nov 19 '06 #1
13 5487
albertw
267 100+
Well, How do i bind a key in Vb6.0? and, i have searched.
hi

what key did you have in mind, and bind to what?
Nov 19 '06 #2
hi

what key did you have in mind, and bind to what?
Lets say, W to
Expand|Select|Wrap|Line Numbers
  1. form1.Backcolor = qbcolor (15)
?
Nov 19 '06 #3
albertw
267 100+
Lets say, W to
Expand|Select|Wrap|Line Numbers
  1. form1.Backcolor = qbcolor (15)
?
hi
tak e.g:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2. If KeyCode = vbKeyF2 Then Form1.BackColor = QBColor(15)
  3. End Sub
  4.  
you may chose any key (see MSDN help on KeyDown)
Nov 19 '06 #4
It wont work.
Nov 19 '06 #5
willakawill
1,646 1GB
It wont work.
It will work if you apply the code to the first control that receives the focus when you start your app. This will be the control with a tab index of 0
Nov 19 '06 #6
albertw
267 100+
It will work if you apply the code to the first control that receives the focus when you start your app. This will be the control with a tab index of 0
hi
of course should it be

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyW Then Form1.BackColor = QBColor(15)
End Sub

how stupid to assign F2 to the color white ... :(
Nov 19 '06 #7
It will work if you apply the code to the first control that receives the focus when you start your app. This will be the control with a tab index of 0
I don't get it, would you explain it a little bit easier for me ,as i am new to vb.
And Albert, it still doesnt work.
Nov 20 '06 #8
willakawill
1,646 1GB
I don't get it, would you explain it a little bit easier for me ,as i am new to vb.
And Albert, it still doesnt work.
In design view set the KeyPreview property of your form to true
Then Albert's code will work
Nov 20 '06 #9
albertw
267 100+
In design view set the KeyPreview property of your form to true
Then Albert's code will work
sry, will explain ...

Create a form (usually the name will be Form1 if you don't change it)
then doubleclick in your newly made form --> a new (blank) screen will open with statement Sub Form_Load()
in righthand top corner you find a dropdown listbox -- select here:
KeyDown
Now a new sub will be opened called Form_KeyDown(....
paste the previous code inhere
beware not to use sub Form_KeyDown and End Sub twice
now, when you start your project (F5) the program will rub, doing NOTHING untill you press the key W, then your form should turn pale
Nov 20 '06 #10
sry, will explain ...

Create a form (usually the name will be Form1 if you don't change it)
then doubleclick in your newly made form --> a new (blank) screen will open with statement Sub Form_Load()
in righthand top corner you find a dropdown listbox -- select here:
KeyDown
Now a new sub will be opened called Form_KeyDown(....
paste the previous code inhere
beware not to use sub Form_KeyDown and End Sub twice
now, when you start your project (F5) the program will rub, doing NOTHING untill you press the key W, then your form should turn pale
ah, now it works. But how do i add more bindings?
Nov 20 '06 #11
sivadhas2006
142 100+
ah, now it works. But how do i add more bindings?
Hi,

To add more key bindings, you can do like this...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2. Select Case KeyCode
  3.      Case vbKeyW
  4.          BackColor = QBColor(15)
  5.      Case vbKeyF
  6.          ForeColor = QBColor(5)
  7.      Case vbKeyM
  8.          MsgBox "Added more keys...", vbInformation
  9. End Select
  10. End Sub
  11.  
Regards,
M.Sivadhas.
Nov 21 '06 #12
THanks, but just one more question, how do i deselect a thing? Like if i would wanna type in something, then press enter too remove it. But now it select the text box and nothing happens when you press enter, except the ding. so, now i want it too deselect the text box when i press enter. Hope you understand.
Nov 21 '06 #13
albertw
267 100+
THanks, but just one more question, how do i deselect a thing? Like if i would wanna type in something, then press enter too remove it. But now it select the text box and nothing happens when you press enter, except the ding. so, now i want it too deselect the text box when i press enter. Hope you understand.
hi

about the same procedure
select your object
doubleclick
then select in the right upper corner e.g: click / doubleclick or KEYDOWN

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
  3. '--- clear text when hitting Enter
  4. If KeyCode = vbKeyReturn Then Text1.Text = vbNullString
  5. '--- clear text when hitting Backspace
  6. If KeyCode = vbKeyBack Then Text1.Text = vbNullString
  7. End Sub
  8.  
  9.  
Nov 21 '06 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Clarence Gardner | last post by:
I've got a problem that I don't see how to program around. A socket server that was running fine, today started getting an exception from the bind() call (errno 22, Invalid argument) and yet the...
1
by: Achille Carette | last post by:
Hello all, I noticed a difference in the explain plans between JDBC using bind variables (PreparedStatement) and SQLPlus for the same query. The query made through JDBC using bind variables...
2
by: P G | last post by:
I hope this is on topic here. I have a problem compiling a simple example of the use of boost::bind. Please take a look at the program below. ...
4
by: Arturo Cuebas | last post by:
The program below contains a compile error. Following the program you will find the typical fix then my idea for a library that facilitates a more elegant fix. #include <boost\bind.hpp> using...
2
by: IndyStef | last post by:
I am trying to use boost's bind on a member function, on the VC8 compiler. After using several different attempts, I could not get it to work. Does anybody know what is wrong with the code below?...
0
by: teclioness | last post by:
Hi, I am using gridview for the user to update rows. In a row, there sre two columns, which need to be updated. When the gridview is to be shown, the row should show the values from database....
1
by: Tigera | last post by:
Greetings, I am trying to learn to use the Boost library, and I've run into a frustrating problem with the line marked here: #include <boost/function.hpp> #include <boost/functional.hpp>...
6
by: crack.the.hack | last post by:
Hi All, If I am changing the database machine, what should I do not to prep bind the sqc files everytime. Because I need to build my application everytime the database is changed? Is there...
5
oranoos3000
by: oranoos3000 | last post by:
hi i read about bind jqeury method general syntax as follow as bind(eventType,data,listener) Establishes a function as the event handler for the specified event type on all elements in...
1
by: victor deng | last post by:
I update db2v8 with new fix18, and do db2 "bind /home/test1/sqllib/bnd/@db2ubind.lst BLOCKING ALL GRANT PUBLIC ACTION ADD". Most of the packages already exist ,so it most errors do not matter. But...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.