VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT

by C.R.RAJAGOPAL- STAR TECHNOLOGIES (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 11th May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



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


Download this snippet    Add to My Saved Code

TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT Comments

No comments have been posted about TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT. Why not be the first to post a comment about TO DETERMINE WHETHER THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT.

Post your comment

Subject:
Message:
0/1000 characters