- Home
·
- Math/Dates
·
- TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT
TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT
TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT
API Declarations
Dim l As Integer
Dim x As String
Dim y As String
Dim z As Integer
'By C.R.Rajagopal STAR TECHNOLOGIES
'E-Mail CRRZUNICA @ YAHOO.COM
'Place one label with caption "number"
'place one small textbox to accept an input number
'place one long textbox to output the result containing some strings
'place first command button cmdresult and caption be result
'place second command button cmdclear and caption be clear
Rate TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT
(1(1 Vote))
Text1.Text = ""
Text2.Text = ""
z = 0
Text1.SetFocus
End Sub
Private Sub cmdresult_Click()
n = CInt(Text1.Text)
l = Len(Str(n))
For i = 1 To l
x = Left$(Str(n), i)
y = Right$(x, 1)
z = z + (Val(y) ^ 3)
Next i
If z = n Then
Text2.Text = "Armstrong Number"
Else
Text2.Text = "Not Armstrong Number"
End If
End Sub
TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT Comments
No comments yet — be the first to post one!
Post a Comment