13-05-2017, 02:35 AM
(10-05-2017, 01:32 PM)medreg كتب :(10-05-2017, 09:09 AM)sabre كتب : أعتقد لأن مطابقت الصورة مع نتيجة تنفيذ الكود قد تمت فعلا
ودليل هناك صورة مرفقة تثبت ذلك
بارك الله فيك اهي صابر لكن حاول تغيير القيمة false الى true في السجل الاول واحسب
من المفروض تكون النتيجة 2000
وحاول تغيير القيمة false الى true في السجل الثاني و ارجع القيمة false في السجل الاول واحسب وانظر ماذا يحصل
من المفروض النتيجة تكون
وهكذا على باقي السجلات
ملاجظة
يجب ان تكون النتيجة في الصف الاخير للفرقة وليس في الصف الاول للفرقة الموالية
وبالتوفيق
يجب ان يكون على هذا الشكل
لقد حلت المشكلة وهذا هو الكود لتعم الفائدة
كود :i: integer; procedure TFrmCalc.btnCalcClick(Sender: TObject); type TMto = array of Double; Tcd = array of String; var Mtot, MT: TMto; cdd, cdb, cda: Tcd; j: integer; tot: Double; Cont: integer; begin i := 0; with DM do begin Cont := Table1.RecordCount; SetLength(Mtot, Cont); SetLength(MT, Cont); SetLength(cdd, Cont); SetLength(cdb, Cont); SetLength(cda, Cont); Table1.DisableControls; try Table1.First; while not table1.Eof do begin if not Table1Active.value then MT[i] := Table1mt.Value; cdd[i] := Table1cdd.AsString; cdb[i] := Table1cdb.AsString; cda[i] := Table1cda.AsString; i := i + 1; Table1.Next; end; finally Table1.EnableControls; end; end; tot := Mt[0]; for j := 1 to Cont-1 do begin if(cdd[j-1]=cdd[j])and(cdb[j-1]=cdb[j])and(cda[j-1]=cda[j])then tot := tot + MT[j] else begin Mtot[j-1] := tot; tot := Mt[j]; end; end; Mtot[j-1] := tot; with DM do begin Table1.DisableControls; try Table1.First; for j := 0 to Cont-1 do begin Table1.Edit; if Mtot[j] = 0 then Table1Mtot.Text := '' else Table1Mtot.Value := Mtot[j]; Table1.Next; end; finally Table1.EnableControls; end; end; end;

