borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (array type)Next Topic (TIMER QUESTION!!!) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Probobly Easy Question Here...
Poster Message
inertiascience
Level: Guest


icon Probobly Easy Question Here...

      Hello, I am a newbie...(gasping sounds are heard in background) and I have a question thats probobly easy to answer, but I am like stuck like someone hot glued my back to a wall.

I need some kind of code that will let me press a button on my keyboard, and depending on which button I press,
(eg. 1, 2, or 3 key) a radio button will act as if it were clicked.

This 'clicking' of the radio button changes the color of a shape. (I put this in this message in case you cant set an ratio button as true from a keyboard button)

The thing is, is I cant get the shape to change color with the key press unless Ive clicked the radio button with my mouse and pressed the key on my keyboard. I dont want to use the mouse at all in my program though.
This is the code I used to get this result:

Private Sub Option1_KeyPress(KeyAscii As Integer)
KeyAscii=Int(1)
Shape1.BackColor=&HFFFF&
Shape2.Backcolor=&HC0C0C0
Shape3.Backcolor=&HC0C0C0
End Sub

In this code, the radio button is called "option1" and the Shape that changed color is named "Shape1"

I really need help, this project is due very very very (a day passes) very very soon...     


[Edited by inertiascience on 22-02-2003 at 08:48 PM GMT]

23-02-2003 at 02:37 AM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Probobly Easy Question Here...

Use the FORM's Keypress

' This should change colors based on 1,2, or 3 being pressed
Private Sub Form_KeyPress(KeyAscii As Integer)
    Select Case Chr(KeyAscii)
        Case "1"
        ' Number 1 pressed
            Shape1.BackColor=&HFFFF&
        Case "2"
        ' Number 2 pressed
            Shape2.Backcolor=&HC0C0C0
        Case "3"
        ' Number 3 pressed
            Shape3.Backcolor=&HC0C0C0
    End Select
End Sub
' You could also just call the option button routine
' Or put in "Option1.Value = True"


[Edited by JLRodgers on 22-02-2003 at 09:20 PM GMT]

____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

23-02-2003 at 03:19 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
inertiascience
Level: Guest

icon Re: Probobly Easy Question Here...

Shoule I Delete the place where it says:

Private Sub Form_Load()

End Sub

23-02-2003 at 03:43 AM
| Quote Reply
inertiascience
Level: Guest

icon Re: Probobly Easy Question Here...

ARGH!!!!!                            

I put your thing into my code and when I pressed the 1 or the 2 or the 3 keys (after entering debug/preview compile mode), nothing happened  

Please help me! I think this might be due monday!!        

23-02-2003 at 03:55 AM
| Quote Reply
inertiascience
Level: Guest

icon Re: Probobly Easy Question Here...

YES!!!!YES!!!!! YESSS!!!!!!!!      

I FOUND THE PROBLEM!!! ::jumps for joy::

I had the KeyPreview Property set to false (default)

What a stupid default....

Well, that solved those problems! I am like extatic!!!    

23-02-2003 at 04:16 AM
| Quote Reply
inertiascience
Level: Guest

icon Re: Probobly Easy Question Here...

Thank you sooooooo much JL, you are the best!!!

23-02-2003 at 04:22 AM
| Quote Reply
win_dir
Level: VB Guru

Registered: 04-08-2002
Posts: 390
icon Re: Probobly Easy Question Here...

JL i think the newbs happy with the brilliant service you do to the community, tell us whats your proper job?

____________________________
We have a Mustek 5 M/Pix GSm@rt USB Digital Camera
for just £74.03 , offer only on until 30th February!

<AllDuck.com>      

Enquiries/Sales: 0845 430 9862
Fax: 0870 950 4532

25-02-2003 at 05:13 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: Probobly Easy Question Here...

well, win_dir...

he's probably the most expressive we've encountered in the forum, eh?  

guess there really should be one in every board.  

yeah... whaddyadoinreallife, JL?  

____________________________
Been busy trying to take a second degree <--it's not working out...

25-02-2003 at 06:39 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1617
icon Re: Probobly Easy Question Here...

Right now, nothing, well other than writing little programs to help others (both here, and for gaming MODs).

Can't find a VB job since I don't have a Masters in programming, or a Bachleors in Engineering or a CPA degree.

____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

25-02-2003 at 07:56 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Probobly Easy Question Here...

  

It's such a shame that the most conversant of this board (the world's best) has not an adequate job. Moreover, it's a shame that it's requested a bachelor or degree to certify that somebody knows how to do the things that he does daily and perfectly for us all.

I really hope that somebody looking for a good programmer will read these pages, and decide to take advantage to his company by engaging the best one, regardless of studies certifications.

I wish you all the best JL, and thank you for what you've teached to me, and for what you will in the future.


____________________________
Real Programmer can count up to 1024 on his fingers

25-02-2003 at 11:46 PM
View Profile Send Email to User Show All Posts | Quote Reply
win_dir
Level: VB Guru

Registered: 04-08-2002
Posts: 390
icon Re: Probobly Easy Question Here...

i agree with yronium, if anyone was to read through these pages and see how muh he has helped people they would employ him straight away.

Have you ever considered a bit of freelance work? freelancetalk.com is a good although new site to advertise yourself on, i myself did and several weeks later i have a guy from realnetworks emailing me about wanting to work for them, they should have a project coming up soon that i can do.

anyway have a look at it and see what you think because they don't usually require any qualifications just proof of what you can do and i think you have that, at this site.

[Edited by win_dir on 26-02-2003 at 12:49 AM GMT]

____________________________
We have a Mustek 5 M/Pix GSm@rt USB Digital Camera
for just £74.03 , offer only on until 30th February!

<AllDuck.com>      

Enquiries/Sales: 0845 430 9862
Fax: 0870 950 4532

26-02-2003 at 12:48 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VB General : Probobly Easy Question Here...
Previous Topic (array type)Next Topic (TIMER QUESTION!!!) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder