2. Write a VB program to find Armstrong numbers between 1 to 1000 and display it onto the form using function.


Public Function display()
Dim i, n As Integer
Dim r As Integer
Dim s As Integer
For i = 2 To 1000
n = i
s = 0
While n > 0
r = n Mod 10
s = s + (r * r * r)
n = n \ 10
Wend
If i = s Then
Print i
End If
Next
End Function
Private Sub cmdDisplay_Click()
Print “Armsrtong Numbers betwwen 1 To 1000 are : ”
display
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s