Autor Beitrag
Andie
Hält's aus hier
Beiträge: 4

Win 98, WinXP

BeitragVerfasst: Di 13.09.05 14:14 
Hallo,
ich programmiere gerade ein Programm, das die Durchschnittsgeschwindigkeit einer Kugel, die durch eine Brachistochrone rollt errechnet. Dabei bekam ich einige Probleme mit den Variablentypen. Ich weiß z.B. nicht wie man eine String Variable in eine Extended, bzw real Variable Umwandelt, bzw andersherum. :?: Kann und will mir jemand Helfen?
Hier mein (unfertiges) Programm:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Math;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    Edit6: TEdit;
    Label6: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  var schnitt: array[1..1000] of String;
  laenge1, laenge2, hoehe1, hoehe2, genauigkeit, m, vv, v, h, hoehe: String;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var i, zahler: Integer;
begin
laenge1 := edit1.Text;
laenge2 := edit2.Text;
hoehe1 := edit3.Text;
hoehe2 := edit3.Text;
genauigkeit := edit4.Text;
m := edit6.Text;
i := 1;
zahler := 1;
For i := 1 to strtoint(hoehe1) Do begin
  hoehe := m * 9.81 *  h;
  vv := inttostr(strtoint(hoehe) div (strtoint(m) div 2));
  v := power(vv, 1 div 2);
  schnitt[zahler] := v;
  i := i + genauigkeit;
  zahler := zahler +1;
end;
end;

end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 13.09.05 14:27 
Hallo!

Die Umwandlung von Strings in Zahlen bzw. Zahlen in Strings ist recht einfach.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
aString := FloatToStr(aFloat); //"Komma"zahl in String
aFloat := StrToFloat(aString); //String in "Komma"zahl
aString := IntToStr(aInt); //"ganze" Zahl in String
aInt := StrToInt(aString); //String in "ganze" Zahl


An dieser Stelle möchte ich dann auch nochmal Schleichwerbung für meinen Crashkurs Delphi machen. :mrgreen:

Grüße
Christian

P.S.: :welcome: im DF!

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Holgerwa
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 325

WIN XP Pro, Vista Business
Delphi 7 Pro, BDS 2006 Pro
BeitragVerfasst: Di 13.09.05 14:29 
Hallo,

sieh Dir in der Delphi-Hilfe mal die Funktionen
    StrToFloat
    TryStrToFloat
an, die sollten weiterhelfen.

Holger
Andie Threadstarter
Hält's aus hier
Beiträge: 4

Win 98, WinXP

BeitragVerfasst: Di 13.09.05 16:13 
Hallo
danke für die tollen Tipps :D