new - keybord does not work anymore

Post your Gambas programming questions here.
Post Reply
User avatar
vito49
Posts: 8
Joined: Sunday 20th December 2020 8:19am

new - keybord does not work anymore

Post by vito49 »

Hello all, I'm more or less new to Gambas, I was out for about a year, but picked up Gambas again to compose small programs ... just to keep the brain cells going, I'm 71 :D
And now I have a small problem, I can't program the keyboard anymore.
The code:

Code: Select all

Public Sub Form1_KeyPress()                           
 If Key.Code = Key.F5 
      PictureBox1.Picture = Picture[("/home/zzz/zzz/" & "start.jpg")]
       Message("well done")
 Endif     
 End
What am I doing wrong?
Thanks in advance.

BTW: hopefully my English is good enough :oops:
Vito
born 19 may 1949
using Gambas3 for therapy ;)
on a Manjaro XFCE4 PC
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: new - keybord does not work anymore

Post by stevedee »

vito49 wrote: Sunday 20th December 2020 9:43am ...What am I doing wrong?...
I created a new project and added this:-
Public Sub Form_KeyPress()                           
 If Key.Code = Key.F5 
       Message("well done")
 Endif     
End
which works.

It could be that you have written in error: Form1
User avatar
cogier
Site Admin
Posts: 1125
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: new - keybord does not work anymore

Post by cogier »

Hi vito49 and welcome to the Forum.

I agree with Steve that it should be 'Form_KeyPress()' not 'Form1_KeyPress()'. Also I suggest you use 'User.Home' and the '&/' which means you don't have to worry about the correct amount of '/'.
Public Sub Form_KeyPress()    'Form1_KeyPress()

  If Key.Code = Key.F5
    PictureBox1.Picture = Picture[User.Home &/ "zzz/zzz/start.jpg"]   'Picture[("/home/zzz/zzz/" & "start.jpg")]
    Message("well done")
  Endif

End
User avatar
vito49
Posts: 8
Joined: Sunday 20th December 2020 8:19am

Re: new - keybord does not work anymore

Post by vito49 »

cogier wrote: Sunday 20th December 2020 12:07pm
Public Sub Form_KeyPress()    'Form1_KeyPress()

  If Key.Code = Key.F5
    PictureBox1.Picture = Picture[User.Home &/ "zzz/zzz/start.jpg"]   'Picture[("/home/zzz/zzz/" & "start.jpg")]
    Message("well done")
  Endif

End
Hi, that was the error. thanks to you all.
Vito
born 19 may 1949
using Gambas3 for therapy ;)
on a Manjaro XFCE4 PC
Post Reply