![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
![]() Код:
procedure TForm1.StringGrid1Click(Sender: TObject); var a:real; begin StringGrid1.Cells[0,1]:='1'; StringGrid1.Cells[0,2]:='2'; StringGrid1.Cells[0,3]:='3'; StringGrid1.Cells[0,4]:='4'; StringGrid1.Cells[0,5]:='5'; StringGrid1.Cells[0,6]:='6'; StringGrid1.Cells[0,7]:='7'; StringGrid1.Cells[0,8]:='8'; StringGrid1.Cells[0,9]:='9'; StringGrid1.Cells[0,10]:='10'; StringGrid1.Cells[0,11]:='11'; StringGrid1.Cells[0,12]:='12'; StringGrid1.Cells[0,13]:='13'; StringGrid1.Cells[0,14]:='14'; StringGrid1.Cells[0,15]:='15'; StringGrid1.Cells[0,16]:= '16'; StringGrid1.Cells[0,17]:= '17'; StringGrid1.Cells[0,18]:= '18'; StringGrid1.Cells[0,19]:= '19'; StringGrid1.Cells[0,20]:= '20'; StringGrid1.Cells[0,21]:= '21'; StringGrid1.Cells[0,22]:= '22'; StringGrid1.Cells[0,23]:= '23'; StringGrid1.Cells[0,24]:= '24'; StringGrid1.Cells[0,25]:= '25'; StringGrid1.Cells[0,26]:= '26'; StringGrid1.Cells[0,27]:= '27'; StringGrid1.Cells[0,28]:= '28' ; StringGrid1.Cells[0,29]:= '29'; StringGrid1.Cells[0,30]:= '30'; StringGrid1.Cells[0,31]:= '31'; StringGrid1.Cells[0,32]:= 'Итого'; { ----------------------------------------} StringGrid1.Cells[0,0]:= 'Дата' ; StringGrid1.Cells[1,0]:= 'Книг'; StringGrid1.Cells[2,0]:= 'Журналов'; StringGrid1.Cells[3,0]:='Брашюр'; StringGrid1.Cells[4,0]:= 'Карандашей'; StringGrid1.Cells[5,0]:= 'Коратышей'; end; end. Как сложить помогите? |
#2
|
||||
|
||||
![]() Так а что складывать???
Если ячейки Книги Журналы Брошуры Карандаши Коротыши, то... Код:
var i : integer;//цикл summ : real;//первая сумма summ1 : real;//вторая сумма begin summ := 0;//обнуляем первую сумму summ1 := 0;//обнуляем вторую сумму for i:= 1 to 31 do//цикл begin summ := summ+StringGrid1.Cells[0,i];//подсчет первой суммы summ1 := summ1+StringGrid1.Cells[1,i];//подсчет суммы end; end; В начале был Бит, потом Байт и только потом появилось Слово... |
#3
|
|||
|
|||
![]() Не прокатывает пишит ошибку
![]() Код:
procedure TForm1.StringGrid1Click(Sender: TObject); var i : integer;//цикл summ : real;//первая сумма summ1 : real;//вторая сумма begin summ := 1;//обнуляем первую сумму summ1 := 0;//обнуляем вторую сумму for i:= 1 to 31 do//цикл begin StringGrid1.Cells[0,1]:='1'; StringGrid1.Cells[0,2]:='2'; StringGrid1.Cells[0,3]:='3'; StringGrid1.Cells[0,4]:='4'; StringGrid1.Cells[0,5]:='5'; StringGrid1.Cells[0,6]:='6'; StringGrid1.Cells[0,7]:='7'; StringGrid1.Cells[0,8]:='8'; StringGrid1.Cells[0,9]:='9'; StringGrid1.Cells[0,10]:='10'; StringGrid1.Cells[0,11]:='11'; StringGrid1.Cells[0,12]:='12'; StringGrid1.Cells[0,13]:='13'; StringGrid1.Cells[0,14]:='14'; StringGrid1.Cells[0,15]:='15'; StringGrid1.Cells[0,16]:= '16'; StringGrid1.Cells[0,17]:= '17'; StringGrid1.Cells[0,18]:= '18'; StringGrid1.Cells[0,19]:= '19'; StringGrid1.Cells[0,20]:= '20'; StringGrid1.Cells[0,21]:= '21'; StringGrid1.Cells[0,22]:= '22'; StringGrid1.Cells[0,23]:= '23'; StringGrid1.Cells[0,24]:= '24'; StringGrid1.Cells[0,25]:= '25'; StringGrid1.Cells[0,26]:= '26'; StringGrid1.Cells[0,27]:= '27'; StringGrid1.Cells[0,28]:= '28' ; StringGrid1.Cells[0,29]:= '29'; StringGrid1.Cells[0,30]:= '30'; StringGrid1.Cells[0,31]:= '31'; StringGrid1.Cells[0,32]:= 'Итого'; { ----------------------------------------} StringGrid1.Cells[0,0]:= 'Дата' ; StringGrid1.Cells[1,0]:= 'Книги'; StringGrid1.Cells[2,0]:= 'Брошюры'; StringGrid1.Cells[3,0]:='каратыши'; StringGrid1.Cells[4,0]:= 'Жюрналы'; StringGrid1.Cells[5,0]:= 'карандаши'; summ := StringGrid1.Cells[1,i];//подсчет первой суммы summ1 := summ1+StringGrid1.Cells[1,i];//подсчет суммы end; end; end. Это то что я пишу мож неправильно что? lmikle: Еще один такой пост без тегов - и будет бан!!! Последний раз редактировалось padavanLS1000, 03.01.2010 в 22:47. |
#4
|
||||
|
||||
![]() Во первых
Процитирую сам себя... Цитата:
Какую ошибку выдает? В третьих У меня тож заметил пару ошибочек В четвертых Я показал лишь пример, а не готовый код Ну, раз я пропустил свои ошибки, то хочу загладить вину... Попробуй так... Код:
procedure TForm1.StringGrid1Click(Sender: TObject); var i : integer;//цикл summ : real;//Книги summ1 : real;//Брошюры summ2 : real;//Каратыши summ3 : real;//Журналы summ4 : real;///Карандаши begin summ := 0; summ1 := 0; summ2 := 0; summ3 := 0; summ4 := 0; //Заполнение постоянных данных таблицы //Наименование строк StringGrid1.Cells[0,1]:='1'; StringGrid1.Cells[0,2]:='2'; StringGrid1.Cells[0,3]:='3'; StringGrid1.Cells[0,4]:='4'; StringGrid1.Cells[0,5]:='5'; StringGrid1.Cells[0,6]:='6'; StringGrid1.Cells[0,7]:='7'; StringGrid1.Cells[0,8]:='8'; StringGrid1.Cells[0,9]:='9'; StringGrid1.Cells[0,10]:='10'; StringGrid1.Cells[0,11]:='11'; StringGrid1.Cells[0,12]:='12'; StringGrid1.Cells[0,13]:='13'; StringGrid1.Cells[0,14]:='14'; StringGrid1.Cells[0,15]:='15'; StringGrid1.Cells[0,16]:= '16'; StringGrid1.Cells[0,17]:= '17'; StringGrid1.Cells[0,18]:= '18'; StringGrid1.Cells[0,19]:= '19'; StringGrid1.Cells[0,20]:= '20'; StringGrid1.Cells[0,21]:= '21'; StringGrid1.Cells[0,22]:= '22'; StringGrid1.Cells[0,23]:= '23'; StringGrid1.Cells[0,24]:= '24'; StringGrid1.Cells[0,25]:= '25'; StringGrid1.Cells[0,26]:= '26'; StringGrid1.Cells[0,27]:= '27'; StringGrid1.Cells[0,28]:= '28' ; StringGrid1.Cells[0,29]:= '29'; StringGrid1.Cells[0,30]:= '30'; StringGrid1.Cells[0,31]:= '31'; StringGrid1.Cells[0,32]:= 'Итого'; //Наименование столбцов StringGrid1.Cells[0,0]:= 'Дата' ; StringGrid1.Cells[1,0]:= 'Книги'; StringGrid1.Cells[2,0]:= 'Брошюры'; StringGrid1.Cells[3,0]:= 'Каратыши'; StringGrid1.Cells[4,0]:= 'Журналы'; StringGrid1.Cells[5,0]:= 'Карандаши'; //Цикл подсчета сумм for i:= 1 to 31 do begin summ := summ + StrToFloat(StringGrid1.Cells[1,i]); summ1 := summ1 + StrToFloat(StringGrid1.Cells[2,i]); summ2 := summ2 + StrToFloat(StringGrid1.Cells[3,i]); summ3 := summ3 + StrToFloat(StringGrid1.Cells[4,i]); summ4 := summ4 + StrToFloat(StringGrid1.Cells[5,i]); end; //Заполнение переменных данных StringGrid1.Cells[1,32]:= FloatToStr(summ); StringGrid1.Cells[2,32]:= FloatToStr(summ1); StringGrid1.Cells[3,32]:= FloatToStr(summ2); StringGrid1.Cells[4,32]:= FloatToStr(summ3); StringGrid1.Cells[5,32]:= FloatToStr(summ4); end; В начале был Бит, потом Байт и только потом появилось Слово... Последний раз редактировалось NIch, 03.01.2010 в 23:33. |
#5
|
|||
|
|||
![]() Код:
procedure TForm1.StringGrid1Click(Sender: TObject); var a : real; b : real; C : real; begin StringGrid1.Cells[0,0]:='Действие'; StringGrid1.Cells[0,1]:='A'; StringGrid1.Cells[0,2]:='B'; StringGrid1.Cells[0,3]:='A+B='; StringGrid1.Cells[1,0]:='Введите число'; a:= StrTOFloat(StringGrid1.Cells[1,2]); b:= StrTOFloat(StringGrid1.Cells[1,3]); c:=A+b; StringGrid1.Cells[1,4]:=FloatTOStr(c); Последний раз редактировалось padavanLS1000, 06.01.2010 в 20:03. |
#6
|
||||
|
||||
![]() Вроде все верно, ошибка где то не тут...
В начале был Бит, потом Байт и только потом появилось Слово... |
#7
|
|||
|
|||
![]() Может я что не выставил в обектном инспекторе?.
|
#8
|
|||
|
|||
![]() TryStrTOFloat Люди пишут что както с этим связанно что вроде вместо StrToFloat надо ставить попробовал не компелируется. Вобщем проблема в пустых ячейках в начале наверное.
![]() |
#9
|
||||
|
||||
![]() На какой строке останавливается в момент ошибки...
Поставь BreakPoint на этой строчке Код:
StringGrid1.Cells[0,0]:='Действие'; Запускай прогу через Delphi, нажимай на StringGrig, прога должна остановится на этой точке... Далее нажимай F7 пока не попадешь на свою ошибку, тогда можно конкретнее узнать. В начале был Бит, потом Байт и только потом появилось Слово... |