Autor Beitrag
erikh112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20

WIN 2000

BeitragVerfasst: So 16.07.06 16:38 
Hallo,

kann mir jemand sagen, wie ich aus einem bereits erstellen string grid eine bestimmte Zelle auslesen??
Sollte diese dann weiterverarbeiten...

Danke

Gruß

E
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 16.07.06 16:49 
Hallo

ausblenden Delphi-Quelltext
1:
s:=stringgird1.cells[Spalte,reihe];					


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
erikh112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20

WIN 2000

BeitragVerfasst: So 16.07.06 17:38 
stimmt oh man alzheimer lässt grüßen,

jetzt meckert er noch, dass es keine integer wert ist..
gibts da nen trick wie ich den Wert der Zelle in ein Integer bzw. Real umwandeln kann?

Danke für die schnelle Hilfe...
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 16.07.06 17:40 
Ein StringGrid heißt so weil es ein Gitter von Strings ist. mit StrToxx kannst du den Werti in den Typ xx wandeln.

_________________
Markus Kinzler.
erikh112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20

WIN 2000

BeitragVerfasst: So 16.07.06 17:44 
jetzt meldet er "-22,75" ist kein gültiger gleitkommawert...

hab mal den code kopiert... vielleicht hat da jemand nen trick parat...

Zitat:

u:=StrtoFloat(E_N.Text);
schritt:=trunc(u/100);

Form3.ImageBG.Canvas.Pen.Color:=clwhite;
Form3.ImageBG.Canvas.Brush.Color:=clwhite;
Form3.ImageBG.Canvas.Rectangle(0,0,500,200);
Form3.ImageX.Canvas.Pen.Color:=clwhite;
Form3.ImageX.Canvas.Brush.Color:=clwhite;
Form3.ImageX.Canvas.Rectangle(0,0,520,25);
Form3.Show;
F:=0;
xfaktor:=N/500;
yfaktor:=45/200;
for i:=0 to 99 do
s:=StrtoInt(Form2.stringgrid1.cells[1,1+i]);
x:=trunc(F/xfaktor);
y:=trunc(s/yfaktor);
Form3.ImageBG.Canvas.Pixels[x,y]:=clblack;
Form3.ImageBG.Canvas.Pixels[x,y+1]:=clblack;
Form3.ImageBG.Canvas.Pixels[x+1,y]:=clblack;
Form3.ImageBG.Canvas.Pixels[x+1,y+1]:=clblack;
F:=F+100;
i:=i+1;
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 16.07.06 17:50 
Setzte die gloable Konstante DecimalSeparator auf den gewünschten Dezimaltrenner.

_________________
Markus Kinzler.
erikh112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20

WIN 2000

BeitragVerfasst: So 16.07.06 17:58 
oh mein gott, wo find ich denn das ? Und was muss ich da genau eintragen.. sorry das hab ich noch nie gehört...

danke
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 16.07.06 18:02 
Einfach

ausblenden Delphi-Quelltext
1:
DecimalSeparator := ',';					

_________________
Markus Kinzler.
erikh112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20

WIN 2000

BeitragVerfasst: So 16.07.06 18:13 
irgendwie will das nicht so wie ich will,
weiß auch ehrlich gesagt nicht wo ich die zeile einfügen soll.


unit Federkraftbestimmung;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons, berechnungen;

type
TForm1 = class(TForm)
Image1: TImage;
B_berechnen: TButton;
E_a: TEdit;
E_b: TEdit;
E_cf: TEdit;
E_c: TEdit;
e_d: TEdit;
E_e: TEdit;
E_r: TEdit;
E_N: TEdit;
E_m: TEdit;
E_l0: TEdit;
L_l0: TLabel;
L_m: TLabel;
B_close: TButton;
L_alpha: TLabel;
L_alpha_ausgabe: TLabel;
B_wertetabelle: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
B_diagramm: TButton;
procedure B_berechnenClick(Sender: TObject);
procedure B_closeClick(Sender: TObject);
procedure B_wertetabelleClick(Sender: TObject);
procedure B_diagrammClick(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;
a,b,c,d,e,N,r,cf,l0,m : extended;
kraft_schritt, kraft_start, kraft: extended;

implementation

uses wertetabelle, Diagramm;

{$R *.dfm}

procedure TForm1.B_berechnenClick(Sender: TObject);
var
ueberpruefen : boolean;
begin

try

a:=StrtoFloat(E_a.Text);
b:=StrtoFloat(E_b.Text);
c:=StrtoFloat(E_c.Text);
d:=StrtoFloat(E_d.Text);
e:=StrtoFloat(E_e.Text);
r:=StrtoFloat(E_r.Text);
cf:=StrtoFloat(E_cf.Text)*0.001;
l0:=StrtoFloat(E_l0.Text);
m:=StrtoFloat(E_m.Text);
N:=StrtoFloat(E_N.Text);

except
showmessage ('Nur Zahlenwerte eingeben, bitte überprüfen!');
end;

if e>c then ueberpruefen:=false
else ueberpruefen:=true;
if c<d then ueberpruefen:=false
else ueberpruefen:=true;
if e>d then ueberpruefen:=false
else ueberpruefen:=true;

if ueberpruefen=true then showmessage('Unsinnige Eingabewerte, bitte überprüfen!')

else

L_alpha_ausgabe.caption:=(floattostr(berechnung_winkel_alpha(a,b,c,d,e,r,cf,l0,m,N)))+'°';
end;


procedure TForm1.B_closeClick(Sender: TObject);
begin
form1.close;
end;



procedure TForm1.B_wertetabelleClick(Sender: TObject);
var
i : integer;
zwischenwert : extended;
ueberpruefen : boolean;
begin
try

a:=StrtoFloat(E_a.Text);
b:=StrtoFloat(E_b.Text);
c:=StrtoFloat(E_c.Text);
d:=StrtoFloat(E_d.Text);
e:=StrtoFloat(E_e.Text);
r:=StrtoFloat(E_r.Text);
cf:=StrtoFloat(E_cf.Text)*0.001;
l0:=StrtoFloat(E_l0.Text);
m:=StrtoFloat(E_m.Text);
N:=StrtoFloat(E_N.Text);

except
showmessage ('Nur Zahlenwerte eingeben, bitte überprüfen!');
end;
if e>c then ueberpruefen:=false
else ueberpruefen:=true;
if c<d then ueberpruefen:=false
else ueberpruefen:=true;
if e>d then ueberpruefen:=false
else ueberpruefen:=true;

kraft_start:=N/100;
kraft_schritt:=N/100;
N:=kraft_schritt;
Form2.stringgrid1.rowcount:=102;
Form2.Stringgrid1.Cells[0,0]:='Kraft (N)';
Form2.Stringgrid1.Cells[1,0]:='Alpha (°)';
Form2.Stringgrid1.Cells[0,1]:=Floattostr(kraft_start);
Form2.Stringgrid1.Cells[1,1]:=Floattostr(berechnung_winkel_alpha(a,b,c,d,e,r,cf,l0,m,N));


i:=1;
repeat
N:=(kraft_start+i*kraft_schritt);
Form2.Stringgrid1.Cells[0,i+1]:=Floattostr(kraft_start+i*kraft_schritt);
Form2.Stringgrid1.Cells[1,i+1]:=Floattostr(berechnung_winkel_alpha(a,b,c,d,e,r,cf,l0,m,N));
i:=i+1;
until i=100;


Form2.show;
end;

procedure TForm1.B_diagrammClick(Sender: TObject);
var i,m,x,y,achse,schritt,F : integer;
xfaktor,yfaktor : real;
u,s : real;
begin

u:=StrtoFloat(E_N.Text);
schritt:=trunc(u/100);

Form3.ImageBG.Canvas.Pen.Color:=clwhite;
Form3.ImageBG.Canvas.Brush.Color:=clwhite;
Form3.ImageBG.Canvas.Rectangle(0,0,500,200);
Form3.ImageX.Canvas.Pen.Color:=clwhite;
Form3.ImageX.Canvas.Brush.Color:=clwhite;
Form3.ImageX.Canvas.Rectangle(0,0,520,25);
Form3.Show;
F:=0;
xfaktor:=N/500;
yfaktor:=45/200;
for i:=0 to 99 do
s:=StrtoInt(Form2.stringgrid1.cells[1,1+i]);
x:=trunc(F/xfaktor);
y:=trunc(s/yfaktor);
Form3.ImageBG.Canvas.Pixels[x,y]:=clblack;
Form3.ImageBG.Canvas.Pixels[x,y+1]:=clblack;
Form3.ImageBG.Canvas.Pixels[x+1,y]:=clblack;
Form3.ImageBG.Canvas.Pixels[x+1,y+1]:=clblack;
F:=F+100;
i:=i+1;
if achse=1 then begin
Form3.ImageX.Canvas.TextOut(x,10,floattostr(trunc(F)));
achse:=achse+1;
end
else begin
achse:=achse+1;
if achse=trunc(xfaktor) then achse:=0
end;



end;

end.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 16.07.06 18:19 
Die Konvertierungsfunktionen greifen auf diese Konstante zu. Du mußt vor dem Konvertieren diese nur setzen:

ausblenden Delphi-Quelltext
1:
2:
3:
try
  DecimalSeparator := ',';
  a:=StrtoFloat(E_a.Text);


BTW. Warum verwendest du keine Delphi-Tags?

_________________
Markus Kinzler.
erikh112 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 20

WIN 2000

BeitragVerfasst: So 16.07.06 18:36 
Kommt immernoch die Fehlermeldung dass "-22,57 kein Gültiger Integerwert ist".
Ich muss allerdings auch mit negativen Zahlen weiterrechnen.


Irgendwo muss der Fehler in der Diagrammerstellung liegen...

Sonst noch ein Tipp??
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: So 16.07.06 18:42 
egal ob komma oder punkt: ein integer ist ein ganzzahlwert und hat keine nachkommastellen. nimm statt strtoint strtofloat und wenn es wirklich ein integer wert sein soll, dann runde den wert, der bei strtofloat rauskommt. irgendwo hast du noch ein strtoint stehen, suche es.

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)