The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
The Failanator
Posted by: Epic Fail of EPICFAILNESS! | May 19, 2011 @ 1:59pm
Delphi Code
[
Download
]
unit Marks_u; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls; type TfrmMarks = class(TForm) lblName: TLabel; edtName: TEdit; btnFind: TButton; redOut: TRichEdit; lblAverage: TLabel; lblAveOut: TLabel; procedure FormActivate(Sender: TObject); procedure btnFindClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var frmMarks: TfrmMarks; implementation {$R *.dfm} procedure TfrmMarks.btnFindClick(Sender: TObject); var NamesFile : TextFile; sName,sNameRead,sNameOut,sSurname,sMark,sIn : String; iPosBlank,iPosCom : Integer; bTest : Boolean; rAverage : Real; begin sName := edtName.Text; if FileExists('Names.txt') <> True Then Begin MessageDlg('File Does not Exist',mtError,[mbOk],0); Exit; End; AssignFile(NamesFile,'Names.txt'); Reset(NamesFile); bTest := False; rAverage := 0; while NOT EoF(NamesFile) do Begin ReadLn(NamesFile,sIn); iPosBlank := Pos(' ',sIn); iPosCom := Pos(',',sIn); sNameRead := Copy(sIn,1,iPosBlank-1); sNameOut := Copy(sIn,1,iPosCom-1); sMark := Copy(sIn,iPosCom+1,(Length(sIn))- ((Length(sNameOut))-2)); sSurname := Copy(sIn,iPosBlank+1,Length(sIn)-iPosBlank - (Length(sMark) + 1)); if (sNameRead = sName) OR (sSurname = sName) OR (sNameOut = sName) then Begin rAverage := rAverage + StrToInt(sMark); lblAveOut.Caption := FloatToStr(rAverage); bTest := True; redOut.Lines.Add(sNameOut + #9 + sMark); End; End; if bTest <> True Then Begin MessageDlg('No Results Found.' + #10 + 'Please Try a Different Name.' + #10 + 'Check that the spelling is Correct.',mtError,[mbOk],0); edtName.Clear; edtName.SetFocus; End; CloseFile(NamesFile); end; procedure TfrmMarks.FormActivate(Sender: TObject); begin redOut.Paragraph.TabCount := 1; redOut.Paragraph.Tab[0] := 100; redOut.SelAttributes.Style := [fsbold]; redOut.Lines.Add('Name:' + #9 + 'Mark:'); redOut.SelAttributes.Style := []; end; end.
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.18 / 8
39 Votes
http://codebin.yi.org/1275
page generated in 0.01 seconds