Autor Beitrag
Fichte-BG
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Fr 20.05.05 10:37 
Hay @all

Ich bin Neuling im Gebiet Delphi und habe da eine Frage ich schreibe mir gerade ein Programm wo ich 2 Werte Aneinander Fügen muss zbs. so.

Zahl1 = 1
Zahl2 = 1

dann muss daraus 11 werden und nicht 2 also beide Zahlen aneinander und das ganze muss ich dann noch rechnen.?


Kann mir jemand sagen wie ich das machen kann.?


MFG: Fichte-BG
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 20.05.05 10:42 
:welcome: im DF!! :D

ausblenden Delphi-Quelltext
1:
2:
3:
4:
function MergeIt(zahl1: Integer; zahl2: Integer): Integer;
begin
result := StrToInt(IntToStr(zahl1)+IntToStr(zahl2));
end;


;)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 20.05.05 10:42 
Ich bin nicht sicher, ob das dein Problem löst, aber eine Möglichkeit ist, beide Zahlen in einen String zu konvertieren, hinterinanderzupacken, und wieder zurückzukonvertieren:
ausblenden Delphi-Quelltext
1:
strtoint(inttostr(zahl1)+inttostr(Zahl2));					

Oder meinst du eher so was:
ausblenden Delphi-Quelltext
1:
Ergebnis:=10*zahl1 + zahl2;					


EDIT: Zwei Sachen: Von mir natürlcih auch ein :welcome: und:
mal wieder zu langsam... :lol:

_________________
We are, we were and will not be.
Fichte-BG Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Fr 20.05.05 10:49 
Hallo ihr zwei.


Super Geil man bekommt ja sofort Antwort das möchte man bei manchen Foren auch gerne haben. :D

Aber danke euch beiden es Funktioniert mit Gausi seiner Methode 1.



MFG: Fichte-BG
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 20.05.05 10:52 
:gruebel:
Wieso soll meins nicht funktionieren?!?! :motz:

Nee, im Ernst? Bei mir geht's! ;)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 20.05.05 10:54 
user profile iconFichte-BG hat folgendes geschrieben:
Aber danke euch beiden es Funktioniert mit Gausi seiner Methode 1.
Welche ja identisch ist mit WeBsPaCe seiner Methode. Damit er sich nicht aufregt... Ach mist, schon wieder zu langsam... :lol:

_________________
We are, we were and will not be.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 20.05.05 10:59 
:bawling: Ich fühl mich sooooo schlecht... :cry: :bawling:

Du musst die function natürlich noch bei dir einfügen. Probier's doch einfach mal so: Du machst ein komplett neues Programm auf. Dann setzt du NUR einen Button auf's Formular. Den klickst du doppelt an. Da schreibst du folgendes rein:
ausblenden Delphi-Quelltext
1:
ShowMessage ( IntToStr ( MergeIt ( 5 , 8 ) ) );					


Jetzt suchst du obendrüber folgende Zeile:
ausblenden Delphi-Quelltext
1:
procedure TForm1.Button1Click(Sender: TObject);					


Und über diese Zeile fügst du dann folgendes ein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function MergeIt(zahl1: Integer; zahl2: Integer): Integer;
begin
result := StrToInt(IntToStr(zahl1)+IntToStr(zahl2));
end;


Das ganze Programm sollte jetzt ungefähr so aussehen:
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function MergeIt(zahl1: Integer; zahl2: Integer): Integer;
begin
result := StrToInt(IntToStr(zahl1)+IntToStr(zahl2));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage ( IntToStr ( MergeIt (5 , 8 ) ) );
end;

end.


;)

@Gausi: Ich reg mich doch nicht auf... :motz: Argh!! :motz: :mrgreen:
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 480

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 20.05.05 11:07 
user profile iconWeBsPaCe hat folgendes geschrieben:
@Gausi: Ich reg mich doch nicht auf... :motz: Argh!! :motz: :mrgreen:
Dann ist ja gut. Ich hatte schon ein schlechtes Gewissen bekommen, weil ich mit Lob- und Ruhmeshymnen überschüttet wurde, und du nicht :angel: :lol:

_________________
We are, we were and will not be.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Fr 20.05.05 11:11 
Als Anfänger hätte ich auch nicht gewusst, wo ich eine function hintun soll. ;)

@Fichte-BG:
Schau doch mal hier rein. ;)