⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delphi tutorial, start here (level 1)..htm

📁 A simple Delphi programming example, with details applicable to any Delphi project.
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<br>

<br>Try running the program, no effect should be apparent yet, but there should be no error messages, either!

<br>

<br>u) Use the Object Inspector to display TMA26f1's properties and events. Click on the Events tab. Double-clcik on the OnCreate even. Put the following between the Begin and End pair

<br>

<br>PickProb;

<br>

<br>Run the program. Other than saying that 5+2 is 4, all should be well.

<br>

<br>v) Add <i><b>to</b></i> PickProb, making it what appears below. N.B. I said "Add <i><b>to</b></i>"... Do not type all of what you see here, just the new bits.

<br>

<br>procedure PickProb;

<br>begin

<br>TMA26f1.lNum1.caption:=IntToStr(random(9));

<br>TMA26f1.lNum2.caption:=IntToStr(random(9));

<br>end;

<br>

<br>AND add <i><b>to</b></i> TTMA26f1.FormCreate to make it:

<br>

<br>procedure TTMA26f1.FormCreate(Sender: TObject);

<br>begin

<br>Randomize;

<br>PickProb;

<br>end;

<br>

<br>(Without that randomize in FormCreate, you get the same problems each time. You can find out more about individual Borland provided functions and procedures by putting the cursor in the name and doing ctrl-F1)

<br>

<br>When you run the program, you should get different numbers to add, even though '4' is still always the 'right' answer.

<br>

<br>Save project again!

<br>

<br>w) About a third of the way down TMA26u1.pas, you'll find

<br>

<br>var

<br>.  TMA26f1: TTMA26f1;

<br>

<br>On the next line add

<br>

<br>.  sAns:string;

<br>

<br>Also, in procedure PickProb, just before its 'end;', add

<br>

<br>.  sAns:='5';

<br>

<br>Also, in procedure TTMA26f1.eAnsChange, make the first line say

<br>

<br>.  if eAns.text=sAns then begin

<br>

<br>And run the program. Now the 'right' answer is always 5, once you have everything correct.

<br>

<br>x) Change the sAns:='5'; in PickProb to

<br>

<br>.  sAns:=IntToStr(StrToInt(TMA26f1.lNum1.caption)+StrToInt(TMA26f1.lNum2.caption));

<br>

<br>At last, the program should only say 'yes' for the right answer!!

<br>

<br>y) Add a button to the form (icon has 'ok' on it.) Name it bGoOn, make caption say 'Click this to go on'. Add the following to TTMA26f1.FormCreate

<br>

<br>bGoOn.hide;

<br>

<br>Add the following to TTMA26f1.eAnsChange just after lRemark.caption:='Yes';

<br>

<br>.   bGoOn.show;

<br>

<br>Make the OnClick event of bGoOn be

<br>

<br>begin

<br>bGoOn.hide;

<br>PickProb;

<br>eAns.setfocus;

<br>end;

<br>

<br>(The program will run without the eAns.setfocus, but you have to click on eAns before each answer.)

<br>

<br>+++++++++++++++++++++++++++

<br>

<br>There you have it! A working program. (And I didn't even massage this text to get the step lettering to come out so well.)

<br>

<br>__________

<br>

<br>Was it of any use? Please send an email, at least. (If you would be interested in more tutorials like this, say so. I'll try to remember to notify you if they become available.)

<br>

<br>Even better, download a piece of my software, try it and pass it on to someone?

<br>

<br>Cheers, Tom Boyd

<br>

<br>www.arunet.co.uk/tkboyd/offers.htm

<br>

<br><<Things that need to be added...

<br>

<br>Notes on editing names, link bewteen object inspector and source code.

<br>

<br>Notes on removing superfluous proc skeletons

<br>

<br><!-----<<<<HTML FOOTER STARTS HERE>>>> Edit off to get text of tutorial -->

<!-- -->



<hr>

<!-- Search engine... pasted from email from FreeFind, on init of this a/c, 13 Apr 00-->

<table>

<td>

<center>

<FORM ACTION="http://search.freefind.com/find.html"

METHOD="GET" target="_top">

&nbsp;&nbsp;

<font size=1 face="arial,helvetica" >

<A

HREF="http://search.freefind.com/find.html?id=2003586">

Search this site</A>

or

<A

HREF="http://search.freefind.com/find.html?id=2003586&t=w">

the web</a>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

powered by <A HREF="http://www.freefind.com">FreeFind</A><br>

<INPUT TYPE="HIDDEN" NAME="id" SIZE="-1" VALUE="2003586">

<INPUT TYPE="HIDDEN" NAME="pid" SIZE="-1" VALUE="r">

<INPUT TYPE="HIDDEN" NAME="mode" SIZE="-1" VALUE="ALL">&nbsp;

<INPUT TYPE="TEXT" NAME="query" SIZE="20">

<INPUT TYPE="SUBMIT"

VALUE=" Find! "><input type="SUBMIT"

name="sitemap" value="Site Map"><br>

</center>

&nbsp;

<input type="radio" name="t" value="s" CHECKED> Site search

<input type="radio" name="t" value="w">Web search

</font></FORM></td></table>

<!--.. and for formless users...-->

<A HREF="http://search.freefind.com/find.html?id=2003586&m=0&p=0">

Site Map</A>&nbsp;&nbsp;&nbsp;

<A HREF="http://search.freefind.com/find.html?id=2003586&w=0&p=0">

What's New</A>&nbsp;&nbsp;&nbsp;

<A HREF="http://search.freefind.com/find.html?id=2003586">

<B>Search</B></A>



<!-- End Search stuff-->





<hr>

<!-- Start Delphi supersite voting links.. graphic 1st, then text -->

<A HREF="http://www.sandbrooksoftware.com/cgi-bin/TopSite2/rankem.cgi?id=tkboyd">

<IMG SRC="dpsc5.gif" HEIGHT="54" WIDTH="79" BORDER="0" ALT="Delphi supersite: vote here"></A>



<A HREF="http://www.sandbrooksoftware.com/cgi-bin/TopSite2/rankem.cgi?id=tkboyd">Please click here to help this site get publicity</A>

<!-- End Delphi supersite voting links -->



<hr>

<h5> <font color="#663333">

Ad from page's editor: Yes.. I do enjoy compiling these things for you...

 hope they are helpful. However.. this doesn't pay my bills!!! If you

 find this stuff useful, (and you run an MS-DOS or Windows pc) please visit my freeware and shareware page,

 download something, and circulate it for me? Links on your page to

 this page would also be appreciated!

</h5>

<font color=#000000>

<p align=center>

<a href="offers.htm">Click here to visit editor's freeware, shareware page.</a>

</p>

<hr>

<!-- -->

<!----->

<a href="Tut.htm">Link to Tutorials main page</a>

<hr>

<a href="Ctact.htm">Here is how</a> you can contact this page's author, Tom Boyd.

<br><br><br>

</body>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -