Autor Beitrag
bigknaller
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Do 24.04.03 20:20 
Ich hab mir eine hübsche ComboBox gemacht... :D
Wenn ich jetzt das erste Item auswähle ( :arrow: ComboBox1Change), soll er mir (es sind in der ComboBox nur Zahlen vorhanden) das Quadrat dieses Items ausrechnen und in einer Variablen speichern. Ich habe es schon mit case und so weiter probiert, aber irgendwie klappt das nicht.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 24.04.03 21:07 
Das ausgewählte Item bekommst Du über ComboBox1.Items[ComboBox1.ItemIndex]. Diesen String in eine Zahl umwandeln, mit sich selbst multiplizieren und un in anderer Variable speichern. Case brauchst Du das gar nicht.

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

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 24.04.03 21:08 
hallo bigknaller!

du hast eine combobox mit zahlen? in meiner stehen immer nur strings drin ;)

aus ausgewählte item bekommst du mit
ausblenden Quelltext
1:
  auswahl:= StrToInt(ComboxBox.Items[ComboBox.ItemIndex])					

(ich glaub, das hab ich schon mal wo im forum gelesen...)

zum quadrieren bindest die unit 'math' ein und
verwendest die function power
hier ist die syntax dazu:
ausblenden Quelltext
1:
function Power(Base, Exponent: Extended): Extended;					


mfg, stefan


Zuletzt bearbeitet von grayfox am Do 24.04.03 21:16, insgesamt 1-mal bearbeitet
bigknaller Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Do 24.04.03 21:09 
Und wenn ich jetzt das zweite Item auswähle?


EDIT: Jetzt funzt es, Vielen Dank euch beiden!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 24.04.03 21:17 
@grayfox: fürs Quadrieren die Unit Math einbinden? Man kann die Zahl doch einfach mit sich selbst multiplizieren, dann kann man sich das sparen.

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

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 24.04.03 21:21 
hallo bigknaller!

hast das property itemindex gesehen?
daher funktioniert es auch mit dem 100ersten eintrag - den 101 muss ich erst testen ;)

mfg, stefan
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Do 24.04.03 21:24 
@peter: so einfach wollt ich's auch net machen.
power sieht viel professioneller aus als
ausblenden Quelltext
1:
ergebnis:= auswahl * auswahl					

findest nicht? :lol:

ich muss nächstes mal schneller tippen, sonst werd ich nie erster ;)

mfg, stefan
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 24.04.03 21:32 
Wie wäre es mit exp(2*ln(abs(auswahl)))? Das sieht noch besser aus und Du brauchst Math nicht. :lol:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Fr 25.04.03 12:59 
...oder wie wär's mit Sqr() ;)?

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 25.04.03 14:02 
Sieht viel zu simpel aus! :wink:

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".