Jump to content

Rakamları Üst Üste Toplama


mesale0077
 Share

Recommended Posts

[codebox]MsgBox(0,"",_TekHane(1231525))

Func _TekHane($number)
if Not IsNumber($number) Then Return -1
Local $return = 10, $ilk = 1
While $return>9
if $ilk Then
$yeniden = StringSplit($number,"")
$ilk = 0
Else
$yeniden = StringSplit($return,"")
EndIf
$return = 0
for $i = 1 to $yeniden[0]
$return += $yeniden[$i]
Next
ConsoleWrite($return&@CRLF)
WEnd
Return $return
EndFunc
[/codebox]

Link to comment
Share on other sites

kodda sıkıntı yaşıyorum
[code]#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("[#] Form1 [#]", 312, 463, 449, 224)
$Input1 = GUICtrlCreateInput("04061984", 16, 80, 257, 21)
$Edit1 = GUICtrlCreateEdit("", 16, 144, 257, 249,BitOR($ES_AUTOVSCROLL,$WS_VSCROLL))
$Label3 = GUICtrlCreateLabel("Sonuç:", 128, 120, 38, 17)
$Button1 = GUICtrlCreateButton("Hesapla", 24, 416, 97, 33)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1


GUICtrlSetData($Edit1,_TekHane(GUICtrlRead($Input1)))




EndSwitch
WEnd
Func _TekHane($number)
if Not IsNumber($number) Then Return -1
Local $return = 10, $ilk = 1
While $return>9
if $ilk Then
$yeniden = StringSplit($number,"")
$ilk = 0
Else
$yeniden = StringSplit($return,"")
EndIf
$return = 0
for $i = 1 to $yeniden[0]
$return += $yeniden[$i]
Next
ConsoleWrite($return&@CRLF)
WEnd
Return $return
EndFunc
[/code]

Link to comment
Share on other sites

[codebox]$Form1 = GUICreate("[#] Form1 [#]", 312, 463, 449, 224)
$Input1 = GUICtrlCreateInput("04061984", 16, 80, 257, 21, 0x2000)
$Edit1 = GUICtrlCreateEdit("", 16, 144, 257, 249)
$Label3 = GUICtrlCreateLabel("Sonuç:", 128, 120, 38, 17)
$Button1 = GUICtrlCreateButton("Hesapla", 24, 416, 97, 33)

GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
GUICtrlSetData($Edit1, _TekHane(GUICtrlRead($Input1)))
EndSwitch
WEnd

Func _TekHane($Number)
Local $ReNumber, $i
Local $Split = StringSplit(String($Number), "")
For $i = 1 To $Split[0]
$ReNumber += Number($Split[$i])
Next
ConsoleWrite($ReNumber & @CRLF)
If $ReNumber > 9 Then $ReNumber = _TekHane($ReNumber)
Return Number($ReNumber)
EndFunc ;==>_TekHane[/codebox]

Link to comment
Share on other sites

"if Not IsNumber($number) Then Return -1" satırını kaldırırsan sorun da ortadan kalkar. yani şöyle olacak fonksiyon.

[code]Func _TekHane($number)
;if Not IsNumber($number) Then Return -1
Local $return = 10, $ilk = 1
While $return>9
if $ilk Then
$yeniden = StringSplit($number,"")
$ilk = 0
Else
$yeniden = StringSplit($return,"")
EndIf
$return = 0
for $i = 1 to $yeniden[0]
$return += $yeniden[$i]
Next
ConsoleWrite($return&@CRLF)
WEnd
Return $return
EndFunc[/code]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...