Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Kalkulator Dodawanie i Odejmowanie


Rekomendowane odpowiedzi

Opublikowano

Witam. Pokaże wam skrypt napisany przeze mnie.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Kalkulator = GUICreate("Kalkulator", 355, 173, 192, 124)
$Cyfra = GUICtrlCreateInput("Cyfra 1", 80, 24, 97, 21)
$Cyfra2 = GUICtrlCreateInput("Cyfra 2", 184, 24, 105, 21)
$Dodaj = GUICtrlCreateCheckbox("Dodaj", 80, 48, 97, 17)
$Odejmij = GUICtrlCreateCheckbox("Odejmij", 80, 64, 97, 17)
$Wynik = GUICtrlCreateButton("Wynik", 128, 96, 107, 41, $WS_GROUP)
$label = GUICtrlCreateLabel("By MrArek1000", 8, 144, 77, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Wynik
           $a = GUICtrlRead($Cyfra)
           $b = GUICtrlRead($Cyfra2)
           If GUICtrlRead($Dodaj) == $GUI_CHECKED Then
               MsgBox(0, "Wynik", $a + $
           EndIf
           If GUICtrlRead($Odejmij) == $GUI_CHECKED Then
               MsgBox(0, "Wynik", $a - $
           EndIf

         Case $GUI_EVENT_CLOSE
           
           Exit
           
    EndSwitch
WEnd

Chodzi tu o to, że on ma checkboxy (przyciski do zaznaczania . NIe wiem jak to inaczej opisać) . Wiem, że powiecie 'Po co taki kalkulator?" Ja odpowiem: Dla ludzi zaczynających zabawę z AutoIT. Mogą popatrzeć na kod, pobawić się nim, pozmieniać funkcję (dlatego nie dodałem mnożenia i dzielenia).

Pozdrawiam, MrArek1000

Opublikowano

Zamiast checkboxa lepsze bylo by radio.

1387536187-U112334.png

Jeśli Ci pomogłem mógłbyś wynagrodzić lajkiem :)

Opublikowano

Tutaj masz mój pierwszy skrypt napisany w AutoIt:

#include <Fizmat.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$form1_1 = GUICreate("CALC BY TEJDI", 480, 444, 318, 178)
$Input1 = GUICtrlCreateInput("", 8, 24, 41, 21)
$Label1 = GUICtrlCreateLabel("Dodawanie", 32, 0, 63, 17)
$Button1 = GUICtrlCreateButton("Licz!", 144, 24, 57, 17)
$Input2 = GUICtrlCreateInput("", 72, 24, 41, 21)
$Label2 = GUICtrlCreateLabel("+", 56, 24, 12, 17)
$Label3 = GUICtrlCreateLabel("Odejmowanie", 32, 48, 68, 17)
$Input3 = GUICtrlCreateInput("", 8, 72, 41, 21)
$Label4 = GUICtrlCreateLabel("-", 56, 72, 7, 17)
$Input4 = GUICtrlCreateInput("", 72, 72, 41, 21)
$Button2 = GUICtrlCreateButton("Licz!", 144, 72, 57, 17)
$Label5 = GUICtrlCreateLabel("Mnożenie", 32, 96, 50, 17)
$Input5 = GUICtrlCreateInput("", 8, 120, 41, 21)
$Label6 = GUICtrlCreateLabel("*", 56, 120, 8, 17)
$Input6 = GUICtrlCreateInput("", 72, 120, 41, 21)
$Button3 = GUICtrlCreateButton("Licz!", 144, 120, 57, 17)
$Button4 = GUICtrlCreateButton("WYJŚCIE", 32, 376, 97, 41)
$Label7 = GUICtrlCreateLabel("Dzielenie", 32, 152, 47, 17)
$Input7 = GUICtrlCreateInput("", 8, 176, 41, 21)
$Label8 = GUICtrlCreateLabel(":", 56, 176, 7, 17)
$Input8 = GUICtrlCreateInput("", 72, 176, 41, 21)
$Button5 = GUICtrlCreateButton("Licz!", 144, 176, 57, 17)
$Label9 = GUICtrlCreateLabel("Potęgowanie", 32, 208, 66, 17)
$Input9 = GUICtrlCreateInput("", 8, 232, 41, 21)
$Do = GUICtrlCreateLabel("Do", 56, 232, 18, 17)
$Input10 = GUICtrlCreateInput("", 80, 232, 25, 21)
$Button6 = GUICtrlCreateButton("Licz!", 144, 232, 57, 17)
$Label10 = GUICtrlCreateLabel("Pierwiastkowanie", 32, 264, 86, 17)
$Label11 = GUICtrlCreateLabel("Pierwiastek z:", 8, 288, 69, 17)
$Input11 = GUICtrlCreateInput("", 80, 288, 49, 21)
$Button7 = GUICtrlCreateButton("Licz!", 144, 288, 57, 17)
$Label12 = GUICtrlCreateLabel("Procenty", 32, 312, 46, 17)
$Input12 = GUICtrlCreateInput("", 8, 328, 57, 21)
$Label13 = GUICtrlCreateLabel("% z", 72, 336, 20, 17)
$Input13 = GUICtrlCreateInput("", 96, 328, 49, 21)
$Button8 = GUICtrlCreateButton("Licz!", 144, 328, 57, 17)
$Label16 = GUICtrlCreateLabel("Energia kinetyczna(masa, prędkosc)", 208, 96, 175, 17)
$masa = GUICtrlCreateInput("", 208, 120, 57, 21)
$predkosc = GUICtrlCreateInput("", 272, 120, 57, 21)
$Button11 = GUICtrlCreateButton("Licz!", 376, 120, 57, 17)
$Label17 = GUICtrlCreateLabel("Energia Potencjalna Grawitacji", 208, 152, 148, 17)
$Label18 = GUICtrlCreateLabel("(masa, wysokosc, ew. zmiana G)", 208, 168, 158, 17)
$Input14 = GUICtrlCreateInput("", 210, 187, 57, 21)
$Input15 = GUICtrlCreateInput("", 274, 187, 57, 21)
$Input16 = GUICtrlCreateInput("9,8", 336, 192, 33, 21)
$Button12 = GUICtrlCreateButton("Licz!", 376, 192, 57, 17)
$Label19 = GUICtrlCreateLabel("Sila wyporu (gestosc, objetosc cieczy, ew. zmiana G)", 216, 224, 253, 17)
$Input17 = GUICtrlCreateInput("", 208, 248, 57, 21)
$Input18 = GUICtrlCreateInput("", 271, 248, 57, 21)
$Input19 = GUICtrlCreateInput("9,8", 335, 248, 33, 21)
$Button13 = GUICtrlCreateButton("Licz!", 376, 248, 57, 17)
$Label20 = GUICtrlCreateLabel("Sila sprezystosci (Wsp, ZmianaDlCiala)", 216, 280, 186, 17)
$Input20 = GUICtrlCreateInput("", 207, 304, 57, 21)
$Input21 = GUICtrlCreateInput("", 271, 304, 57, 21)
$Button14 = GUICtrlCreateButton("Licz!", 376, 304, 57, 17)
$Label21 = GUICtrlCreateLabel("Predkosc Fali (dlugosc f., czestotliwosc)", 216, 328, 192, 17)
$Input22 = GUICtrlCreateInput("", 207, 345, 57, 21)
$Input23 = GUICtrlCreateInput("", 271, 345, 57, 21)
$Button15 = GUICtrlCreateButton("Licz!", 375, 345, 57, 17)
$Pic1 = GUICtrlCreatePic("C:\Users\Hosterovsky\Desktop\huijjR.jpg", 208, 8, 121, 81)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###



While 1
	$nMsg = GUIGetMsg()
	Switch $nMsg
		case $Button15
			$i22 = guictrlread($Input22)
			$i23 = guictrlread($Input23)
			MsgBox(0, "Wynik", "Wynik to: "& $i22 * $i23)
		case $Button14
$i20 = guictrlread($Input20)
$i21 = guictrlread($Input21)
MsgBox(0, "Wynik", "Wynik to: "& $i20 * $i21)

		case $Button13
$i17 = guictrlread($Input17)
$i18 = guictrlread($Input18)
$i19 = guictrlread($Input19)
MsgBox(0, "Wynik", "Wynik to: "& $i17 * $i18 * $i19)
		case $Button12
			$i14 = guictrlread($Input14)
			$i15 = guictrlread($Input15)
			$i16 = guictrlread($Input16)
			MsgBox(0, "Wynik", "Wynik to: " & $i14 * $i15 * $i16)
		case $Button11
$masa1 = guictrlread($masa)
$predkosc2 = guictrlread($predkosc)
			MsgBox(0, "Wynik", "Wynik to: " & ($masa1 * $predkosc2 ^ 2) / 2)
		Case $GUI_EVENT_CLOSE
						For $p = 1 to 10
			MsgBox(0, "Dzięki", "Dzięki za skorzystanie z kalkulatora" & @LF & "By Tejdi aka Mateusz" & @LF & "Dziękuję po raz " & $p & " !")
			Next
			Exit

		case $Button8
			$i = guictrlread($Input12)
			$o = guictrlread($Input13)

			MsgBox(0, "Wynik", $i&" % z liczby "&$o&" to: " & $i / 100 * $o)

		case $Button7
			$u = guictrlread($Input11)
			MsgBox(0, "Wynik", "Wynik to: " & sqrt($u))

		case $Button1
			$x = guictrlread($Input1)
			$y = guictrlread($Input2)
			MsgBox(0, "Wynik", "Wynik to: " & $x + $y)

		case $Button2
			$z = guictrlread($Input3)
			$c = guictrlread($Input4)
			MsgBox(0, "Wynik", "Wynik to: " & $z - $c)

		case $Button3
			$q = guictrlread($Input5)
			$w = guictrlread($Input6)
			MsgBox(0, "Wynik", "Wynik to: " & $q * $w)

		case $Button4
			For $p = 1 to 10
			MsgBox(0, "Dzięki", "Dzięki za skorzystanie z kalkulatora" & @LF & "By Tejdi aka Mateusz" & @LF & "Dziękuję po raz " & $p & " !")
			Next
			Exit

		case $Button5

			$e = guictrlread($Input7)
			$r = guictrlread($Input8)
if $e == 0 Then
	msgbox(0, "Error", "W pierwszej kolumnie nie moze znajdowac sie 0.")
EndIf
if $e == "" Then
	msgbox(0, "Error", "W pierwszej kolumnie musi znajdowac sie liczba.")
EndIf
if $r == 0 Then
	msgbox(0, "Error", "W drugiej kolumnie nie moze znajdowac sie 0.")
EndIf
if $r == "" Then
	msgbox(0, "Error", "W drugiej kolumnie musi znajdowac sie liczba.")
EndIf
if $e <> 0 and $e <> "" and $r <> 0 and $r <> "" then
			MsgBox(0, "Wynik", "Wynik to: " & $e / $r)
endif

		case $Button6
			$t = guictrlread($Input9)
			$y = guictrlread($Input10)
			MsgBox(0, "Wynik", "Wynik to: " & $t ^ $y)
	EndSwitch
WEnd


Opublikowano

@Up2

Wg mnie żadna róznica

@UP

Zastanawiałem się nad zrobieniem takiego czegoś podobnego, bez tej całej prawej strony ale narazie taki malutki mi starczy. Ale ładnie Ci to wyszło

Pozdrawiam, MrArek1000

Opublikowano

@UP

Dzięki, powoli zmierzam do bardziej skomplikowanych zadań na fizykę, bo za rok znów będę musiał się z nią zmagać, a takie narzędzie bardzo to ułatwi.

Myślę też nad kalkulatorem wzorów chemicznych :)

Opublikowano

Wiesz, mi takie coś narazie nie potrzebne. Dopiero w tym roku do gimnazjum idę. Więc jeszcze sporo nauki języków i niedługo może coś zrobię 'większego'.

Pozdrawiam, MrArek1000

Opublikowano

Gdybym wstawiał KAŻDY to byłby totalny spam. Wstawiłem taki słaby, żeby POCZĄTKUJĄCY mogli sobie ogarnąć ŁATWY kod i EDYTOWAĆ.

Pozdrawiam, MrArek1000

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...