Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.pascal.delphi.misc > #624
| From | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
|---|---|
| Newsgroups | comp.lang.pascal.delphi.misc |
| Subject | Re: display array values in a label |
| Date | 2014-09-12 18:01 +0200 |
| Message-ID | <c7gkjuFnou9U1@mid.individual.net> (permalink) |
| References | <917dbf9e-f5aa-4a84-ba56-b1c1ff3e354e@googlegroups.com> <c7dncrFmuvU1@mid.individual.net> <adf4df8d-e0b5-4e07-ac77-01d76a5a83ad@googlegroups.com> |
Sandeepan Kashyap schrieb: > Thanks DoDi, > > I am actually an experienced Mumps/Cache developer and have to learn > Delphi for a new project. I am actually trying to print a series of > number in ascending order, e.g. 1,2,3,4,5,6,7,8,9 but in every number > should print in new followed line. like > 1 > 2 > 3 > .. Let's look into this later, it depends on what you mean by "printing". When you want to show multiple lines on a form, use a TListBox or TMemo, not an TLabel. > I tried the below code. But the below code printing '0' always inside Label3, don't know why? what's is wrong with the code. Please enlighten me. > > type > TIntegerArray = Array[1..9] of Integer; > var > x,y : integer; > txt: string; > i: integer; > arrayOfIntegers : TIntegerArray; > begin > Form1.Color := clGreen; > x := StrToInt(Edit1.Text); > y := StrToInt(Edit2.Text); > > i := 1 ; > begin > while (i = 9) do > arrayOfIntegers[i] := i; > Inc(i); > end; Can you answer these questions: What's the value of i here? What's the value of arrayOfIntegers[i]? > Label3.Caption := IntToStr(arrayOfIntegers[i]); Please try to learn how to use the Delphi debugging features. When you put an breakpoint somewhere in this procedure, e.g. on "i := 1;", you can step through the following code and inspect all variables by moving the mouse pointer over the name of a variable. It even will show you the content of arrayOfIntegers[i], depending on the current value of i. Then you'll find that the array is not initialized, because the condition in while (i = 9) do ... is never True. Okay, this may be a typo, should read (i <= 9) instead? Please fix this and try again. Finally I assume that you expect too much from IntToStr(), in case you want to display *all* array elements at once. That doesn't work, for two reasons: - IntToStr only converts an single value - arrayOfInteger[i] is a single value, not the entire array You need another loop over the array, adding the values to an result string or to a ListBox control. DoDi
Back to comp.lang.pascal.delphi.misc | Previous | Next — Previous in thread | Next in thread | Find similar
display array values in a label Sandeepan Kashyap <sandeepan1982@gmail.com> - 2014-09-11 04:02 -0700
Re: display array values in a label Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-09-11 15:44 +0200
Re: display array values in a label Sandeepan Kashyap <sandeepan1982@gmail.com> - 2014-09-11 23:24 -0700
Re: display array values in a label Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-09-12 18:01 +0200
Re: display array values in a label Sandeepan Kashyap <sandeepan1982@gmail.com> - 2014-09-15 02:34 -0700
Re: display array values in a label Sandeepan Kashyap <sandeepan1982@gmail.com> - 2014-09-15 02:36 -0700
Re: display array values in a label Hans-Peter Diettrich <DrDiettrich1@aol.com> - 2014-09-15 14:14 +0200
Re: display array values in a label "Alan Lloyd" <alanglloyd@NotThisBitbtinternet.com> - 2014-09-25 11:51 +0100
Re: display array values in a label Sandeepan Kashyap <sandeepan1982@gmail.com> - 2014-09-26 05:58 -0700
Re: display array values in a label "Alan Lloyd" <alanglloyd@NotThisBitbtinternet.com> - 2014-09-26 19:53 +0100
csiph-web