Topic: Event Handler must be a procedure

Hello Dmitry and all MVD users. Please Help me out

I get this error "Event Handler Must Be a Procedure". Meanwhile the event is a procedure. Check this and help me out

procedure exeat_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
http: variant;
url,userpassword,username,sms,phone :string;

Begin
    If SqlExecute('Select Count(id_students) FROM exeat WHERE exeat.id_students=' + exeat.combobox2.sqlValue) > 0 then
      begin
         MessageBox('This student is already on Exeat','Error',MB_OK+MB_ICONERROR);
         Cancel := True;
         exeat.combobox2.SetFocus;
         Exit;
      end;
      if ping('google.com') then
         begin
             SQLExecute('INSERT INTO report (exeatfrom, exeatto, purpose, id_students, id_class, action) VALUES('+
             Exeat.DateTimePicker1.sqlDateTime + ', ' + Exeat.DateTimePicker2.sqlDateTime + ', ' +
             Exeat.Memo1.sqlValue + ', ' + Exeat.ComboBox2.sqlValue + ', ' + Exeat.ComboBox1.sqlValue + ', "on Exeat")');
             frmReport.TableGrid1.dbUpdate;

              username := 'hotice@live.com';
              userpassword := 'hot0208914692';
              sms := exeat.Memo3.text;
              phone := exeat.Edit1.text;
              http:=createoleobject('WinHttp.WinHttpRequest.5.1');
              user='+username+'&password='+userpassword+'&message='+sms+'&type=0&sender=SCHOOL NAME&destination='+phone+'';
              browser.Edit1.Text:= url;
              browser.Button1.click;
          end
      else
      begin
          MessageBox('No internet Connection','Error',MB_OK+MB_ICONWARNING);
          Cancel := True;
          Exit;
      end;
 End;

Re: Event Handler must be a procedure

Hi Dmitry, Sibprogsistem, Derek, thezimguy and all MVD users. I really need help on the topic above. Thank you in advance for your constant support.

3 (edited by CDB 2020-06-26 03:59:00)

Re: Event Handler must be a procedure

Humblelion,


Is this definitely where the error occurs?


Have you tried commenting out parts of your code? I mean if you were to comment out If PING to the ELSE temporarily, do you still get the error?


Are you missing any semicolons before your call to this procedure?

On a clear disk you can seek forever

Re: Event Handler must be a procedure

CDB wrote:

Humblelion,


Is this definitely where the error occurs?


Have you tried commenting out parts of your code? I mean if you were to comment out If PING to the ELSE temporarily, do you still get the error?


Are you missing any semicolons before your call to this procedure?


Thank you CDB for the quick response. If I comment out ping,I dont get that error but I need ping to check internet connection. I will be glad if i could get another method for checking internet connection. Thank you once again

5 (edited by CDB 2020-06-26 04:14:49)

Re: Event Handler must be a procedure

I've just looked at MVDs Ping function and perhaps you don't have enough parameters.

It shows  Ping(string,boolean,Timeout)   and returns a boolean.

Perhaps you should try :  Ping('google.com', false, Timeout);   False means you aren't raising an exception on error and Timeout has a default of 1ms.

On a clear disk you can seek forever

6 (edited by CDB 2020-06-26 04:23:20)

Re: Event Handler must be a procedure

Ignore my suggestion above, I've just tried ping('google.com);   in the middle of some code and I get no errors on compilation.


So it looks like a case of commenting out chunks of your 'if ping' statement until you find the culprit.

On a clear disk you can seek forever

Re: Event Handler must be a procedure

CDB wrote:

I've just looked at MVDs Ping function and perhaps you don't have enough parameters.

It shows  Ping(string,boolean,Timeout)   and returns a boolean.

Perhaps you should try :  Ping('google.com', false, Timeout);   False means you aren't raising an exception on error and Timeout has a default of 1ms.

I will give it a try right away and get back to you. Just a minute my brother

Re: Event Handler must be a procedure

CDB wrote:

Ignore my suggestion above, I've just tried ping('google.com);   in the middle of some code and I get no errors on compilation.


So it looks like a case of commenting out chunks of your 'if ping' statement until you find the culprit.

I'm still surprised mine throws out that error.I just don't know what to do again

Re: Event Handler must be a procedure

Are you sure that this procedure causes the problem ? You are calling the browser form 'browser.button1.click' - could it be that there is an error in the procedure that the button uses ?

Re: Event Handler must be a procedure

lupo1st wrote:

Are you sure that this procedure causes the problem ? You are calling the browser form 'browser.button1.click' - could it be that there is an error in the procedure that the button uses ?

Thank you so much for the information. The browser form work perfectly when you run a url in it. Anyway, I will check that again and get back to you. Thank you once again.

Re: Event Handler must be a procedure

lupo1st wrote:

Are you sure that this procedure causes the problem ? You are calling the browser form 'browser.button1.click' - could it be that there is an error in the procedure that the button uses ?

You were right my brother. The problem has to do with the browser form and not the ping. Thank you very much.

Thank you too CDB