Autor Beitrag
Affje
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 04.03.03 18:44 
hi

ich habe ein programm erstellt , mit dem einen preis aus bestimmten, zuvor eingetippten preisen errechnen kann. die preise werden in 4 verschiedene edit-komponenten eingetragen. zum schluss habe ich einen button draufgesetzt, mit dem man die preise dann zusammenrechnen kann. ich folgende zeile verwendet:

label1.caption:=edit1.text + edit2.text + edit3.text + edit4.text;


wenn ich nun das programm starte und etwas in die edit-komponenten eingebe und den knopf zum errechnen drücke, dann sieht es wie folgt aus:

in jeder edit-komponente steht eine zahl, z.b.: 1 im ersten, 2 im zweiten, 3 im dritten, 4 im vierten.
wenn ich den knopf drücke, steht aber nicht 10, sondern 1234 da.

er setzt die zahlen einfach nur hintereinander. wie kann ich aber eine addition ausführen :?: :?: :?:

danke mal im voraus. mfg affje
phase
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Di 04.03.03 18:49 
Hallo,
du addierst hier die Strings, hängst sie also einfach nur hintereinander.
Um allerdings die Werte zu addieren muss du jeden String mit StrToInt() in einen Integer umwandeln. Das wäre dann:
ausblenden Quelltext
1:
label1.caption:=IntToStr(StrToInt(edit1.text) + StrToInt(edit2.text) + StrToInt(edit3.text) + StrToInt(edit4.text));					

Letztendlich muss dann der addierte Wert mittels IntToStr() wieder in einen String umgewandelt werden, bevor er im Label angezeigt werden kann.

Gruß,
phase
Affje Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 04.03.03 19:26 
Titel: danke
vielen dank für deine hilfe
ich kann halt noch nicht so gut programmieren, denn ich bin noch im 1. jahr in der informatik ag unserer schule :(
Affje Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Di 04.03.03 19:52 
funktioniert nicht. da steht: inkompatible typen string und tedit.
was nun???
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Di 04.03.03 19:54 
vieleicht stehen in deinem edit nicht nur zahlen, sondern buchstaben (Dm oder Euro)

oder vieleicht verwendest du ein komma statt einem punkt (wegen der englischen schreibweise)
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 04.03.03 19:59 
Du hast irgendwo das .Text vergessen.

Aber wenn ihr nach einem Jahr noch nicht wißt, dass es unterschiedliche Datentypen gibt und dass es erforderlich sein kann, dass man, je nach dem, vorher konvertieren muß, bevor man weiterarbeiten kann, dann ist bei euch aber mächtig was schiefgelaufen. Oder du hast nur gepennt, was ich aber nicht hoffen will.


Zuletzt bearbeitet von Luckie am Di 04.03.03 20:30, insgesamt 1-mal bearbeitet
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Di 04.03.03 20:06 
meinst du mich?

ich dachte er hat sich vieleicht den code kopiert und nicht abgeschrieben, also hab ich gedacht, dass es ja daran nicht liegen kann.
MathiasH
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 699

WinXP, Win98SE, Debian, Win95
D5 Stand, D6 Prof
BeitragVerfasst: Di 04.03.03 20:34 
nicht denken Thorsten, das geht schief, das können nur Blondienen oder Politiker :lol: :lol: :lol:

Hui ich hab wieder nen tollen witz gerissen *g*

IO-sys/MathiasH

_________________
"Viel von sich reden, kann auch ein Mittel sein, sich zu verbergen."
Friedrich Nietzsche
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Di 04.03.03 20:36 
Zitat:
Hui ich hab wieder nen tollen witz gerissen *g*


Freu dich!!! :wink:
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Di 04.03.03 20:38 
fällt mir gerade auf. torsten wird ohne H geschrieben.


Merke: Torsten Heinze ohne H und ohne T, ABER nicht ohne T und ohne H!!!
Affje Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mi 05.03.03 10:20 
sorry. jetzt läuft alles. habe das .text vergessen :roll: :roll: :roll:
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Mi 05.03.03 17:16 
kopier es doch das nächste mal, und schreibes nicht selber :wink:
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 05.03.03 17:45 
@Affje:
Sag mal welche Jahrgansstufe bist du denn?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Mi 05.03.03 17:47 
also programmieren tut er seit einem jahr, soviel weiß ich von oben
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 05.03.03 18:17 
Das sagt noch nicht viel über sein Alter aus. Mich interessiert das bloß wegen der Informatik AG und noch keine Typumwandlungen.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Mi 05.03.03 18:19 
achso, lernt man eigendlich nicht die typen und deren umwandlung so ziemlich als erstes?

ich weiß es net, ich hab mir delphi selbst beigebracht.
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 05.03.03 19:32 
Da kann ich dir auch nur zustimmen ich weiß es auch nicht denn ich bin auch autodidakt und habe mir das auch sehr früh beigebracht (ich fing mit 13 an).

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Mi 05.03.03 19:43 
hey, ich auch mit 13 (bin jetzt 15)
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mi 05.03.03 20:09 
Ich bin bald 19. Das sind jetzt 6 schöne Jahre :lol:

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mi 05.03.03 21:18 
Ich glaube das muss ich dann mal übertrumpfen: Mit 7 Jahren: Turbo Basic.
Aber das Thema solltet ihr/wir im entsprechenden Thread weiter führen. (wo ist der den verblieben? Mal nicht hingeschaut, und schon ist er weg.)

_________________
Ist Zeit wirklich Geld?