Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

A silly problem

Posted on 2005-05-12
14
Medium Priority
?
539 Views
Last Modified: 2010-04-04
Hello all.
Just started to use Delphi2005.net for a project and having a few silly problems. If i have a messagebox with yes no buttons on screen, what is the code for using an if statement i.e if yes button used do this, if no do that.
My code so far is
messagebox.Show(' No Com Port entered. Do you wish to retry','ERROR',MessageBoxButtons.YesNo,MessageBoxIcon.Question);

Best regards as always
0
Comment
Question by:Paul-Brooks
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13984576
well have no d2005, but i would guess

messagebox.Show is a function
or there is an similar functioncall
or there is a method to read out the result

meikl ;-)
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13984677
I think it uses something called dialogresult

if messagebox.Show(' No Com Port entered. Do you wish to retry','ERROR',MessageBoxButtons.YesNo,MessageBoxIcon.Question) = dialogresult.yes then
0
 

Author Comment

by:Paul-Brooks
ID: 13984781
I have used the Dialogresult.yes then suggestion, but on compiling i get the following error message


[Error] WinForm.pas(221): E2018 Record, object or class type required

Think im going in the right direction, just need easing a little more please
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13984907
Im afraid I dont have Delphi 2005 yet, I have just been scanning through some documents.

I think that you need to create an object of type dialogresult, but unfortunately I dont know what the syntax for this is.
I had a look at some vb.net code and found

Result := dialogresult;
Result := messagebox.Show(' No Com Port entered. Do you wish to retry','ERROR',MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if Result := dialogresult.yes then
  // do something

but unfortunately I cant give you any more information than that.

Im assuming that you need to find the unit with dialogresult in it and create an object of that type to assign to.
Sorry I dont have anything else to give you but I will keep looking.
Hopefully someone else can give you some more information.
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13984912
Sorry that first line should have been

dim Result as dialogresult;

which is vb code

So Im presuming there might be something like

var
  Result: TDialogResult

but that is a total guess
0
 

Author Comment

by:Paul-Brooks
ID: 13985343
Mike
Thanks for you efforts. Help on Delphi2005.net is a bit thin on the ground at the moment. Having set the variable as suggested, compiling now brings up this error
[Error] WinForm.pas(221): E2007 Constant or type identifier expected.

Syntax for Delphi.net is like a hybrid of delphi and vb.net and is becoming very confusing. If anybody knows of any websites with code examples i would be very grateful
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13985658
try

 if MessageBox.Show('No Com Port entered. Do you wish to retry','ERROR',
             MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes then
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13987837
Just as a point of interest, have you got the delphi unit listed in your uses clause for using message dialogs/boxes.
0
 

Author Comment

by:Paul-Brooks
ID: 13987937
I had to add sysutils in my uses clause to make the messageshow function work. can you think of any other's i might need
0
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 800 total points
ID: 13988532
maybe dialogs
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13988542
maybe controls too

though these units are D7 not D2005, so Im presuming they still exist.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13988547
Paul

Are you using VCL.Net applicatio/WinForms Application/or win 32 application?
0
 
LVL 22

Assisted Solution

by:Mohammed Nasman
Mohammed Nasman earned 1200 total points
ID: 13988717
try to write my previous message as

  if MessageBox.Show('No Com Port entered. Do you wish to retry','ERROR',
             MessageBoxButtons.YesNo,MessageBoxIcon.Question) = System.Windows.Forms.DialogResult.Yes  then
0
 

Author Comment

by:Paul-Brooks
ID: 13994319
Many thanks to you all
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question