new - keybord does not work anymore

Post

Posted
Rating:
#1 (In Topic #522)
Avatar
Trainee
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

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:
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Regular
stevedee is in the usergroup ‘Regular’

vito49 said

…What am I doing wrong?…

I created a new project and added this:-

Code (gambas)

  1. Public Sub Form_KeyPress()                          
  2.  If Key.Code = Key.F5
  3.        Message("well done")
  4.  Endif    

which works.

It could be that you have written in error: Form1
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
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 '/'.

Code (gambas)

  1. Public Sub Form_KeyPress()    'Form1_KeyPress()
  2.  
  3.   If Key.Code = Key.F5
  4.     PictureBox1.Picture = Picture[User.Home &/ "zzz/zzz/start.jpg"]   'Picture[("/home/zzz/zzz/" & "start.jpg")]
  5.     Message("well done")
  6.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Trainee

cogier said


Code (gambas)

  1. Public Sub Form_KeyPress()    'Form1_KeyPress()
  2.  
  3.   If Key.Code = Key.F5
  4.     PictureBox1.Picture = Picture[User.Home &/ "zzz/zzz/start.jpg"]   'Picture[("/home/zzz/zzz/" & "start.jpg")]
  5.     Message("well done")
  6.  

Hi, that was the error. thanks to you all.
Online now: No Back to the top
1 guest and 0 members have just viewed this.