+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: error box

  1. #1
    xsmithx
    Guest

    Exclamation error box

    hey there, im new to delphi, and im usin the "Client_Server example" source to learn and play with, when i run the client and click connect when there is no ip enterd i get a error and it crashes, what code can i add so when there is no ip enterd and you try and connect you will get a message box that will pop up tellin you to enter an ip address?
    This is my current code for the "Connection Button"

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if ClientSocket1.Active = False then
    begin
    ClientSocket1.Host := Edit1.Text;
    ClientSocket1.Port := 1533;
    ClientSocket1.Active := True;
    Button1.Caption := 'Disconnect';
    StatusBar1.Panels[0].Text := 'Connected';
    end
    else
    begin
    ClientSocket1.Active := True;
    ClientSocket1.Close;
    Button1.Caption := 'Connect';
    StatusBar1.Panels[0].Text := 'Disconnected';
    end


    Thank You

  2. #2
    Senior Member drkdreams's Avatar
    Join Date
    Jul 2005
    Posts
    165
    hi xsmithx

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    if ClientSocket1.Active = False then
    begin
    ClientSocket1.Host := Edit1.Text;
    ClientSocket1.Port := 1533;
    if Edit1.Text = '' then //put wotever u want to happen here 
    else ClientSocket1.Active := True;
    Button1.Caption := 'Disconnect';
    StatusBar1.Panels[0].Text := 'Connected';
    end
    else
    begin
    ClientSocket1.Active := True;
    ClientSocket1.Close;
    Button1.Caption := 'Connect';
    StatusBar1.Panels[0].Text := 'Disconnected';
    end
    i hope thats right
    Ciao

    -drkdreams
    -Delphi Coder

  3. #3
    xsmithx
    Guest
    will that be in a pop up box? like "Please Enter IP Address" then a OK button?

    Thanks drk dreams

  4. #4
    ratws
    Guest
    This is what you want right ?
    if Edit1.Text = '' then
    MessageBox(Handle,'Please, enter an IP address !!','xsmithx',MB_ICONINFORMATION+MB_OK);

  5. #5
    xsmithx
    Guest
    Yeh thats the one Thanks Ratws,
    when its in run mode, i leave the ip box empty, click connect, i get the "'Please, enter an IP address" message, but then i get
    Project Project1.exe raised exception class EScocketError with message "No Address Specified"
    how can i get this error message to stop popin up, or wont it pop up when i compile it?

    Thank You

  6. #6
    ratws
    Guest
    Click on the clientsocket, in the Object Inspector double click "OnError" and do this..
    ErrorCode:= 0;

  7. #7
    xsmithx
    Guest
    i get "ErrorCode:= 0;" is not a Valid identifier

    Thank you for your help Ratws

  8. #8
    ratws
    Guest
    You don't insert it in the Object Inspector, you just double click in that empty spot right after the "OnError", this will create an event handler and then you insert the codes!

  9. #9
    xsmithx
    Guest
    yeh i tryed that mate i get this look

  10. #10
    ratws
    Guest
    Yeah but, this is what you should not do.You are inserting the codes in the wrong place.Fisrt of all clear that, double click it (it will be empty) and then you insert the codes in the code editor, not in the Object Inspector.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ClientSocket Error
    By ratws in forum Delphi Help
    Replies: 8
    Last Post: 29-09-2005, 02:50
  2. Replies: 23
    Last Post: 03-09-2005, 00:06
  3. Socket error +help
    By WEZ_2511 in forum Delphi Help
    Replies: 3
    Last Post: 02-09-2005, 18:09
  4. Some Lame XP Error (I guess)
    By luigi in forum Off-Topic
    Replies: 7
    Last Post: 09-05-2005, 23:48
  5. LoadFromFile Error :(
    By GencTurK in forum General Programming Help
    Replies: 3
    Last Post: 22-04-2005, 21:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.