answersLogoWhite

0


Best Answer
Dim no As Integer, r As Integer, sum As Integer = 0, n As Integer = 0


Console.WriteLine("Enter number" & vbLf)



no = Int32.Parse(Console.ReadLine())


n = no


While n > 0


r = n Mod 10


n = n \ 10


sum += r * r * r


End While



If sum = no Then


Console.WriteLine("{0} is a Amstrong number", no)


Else


Console.WriteLine("{0} is not a Amstrong number", no)


End If


Console.ReadLine()

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

8y ago

Create a textbox a label and a button

paste the code on button click.

Dim i, a, b, c, sum As Integer 'Declare variable i,a,b,c,and sum

Label1.ForeColor = &HC000& 'Change the font color of the ouput label

i = Val(Text1.Text) 'Assign text1 value to i

a = i \ 100 'Divide the i value by 100 and take the real part

b = (i Mod 100) \ 10 'Use mod to remove the first number and divide by 10-> take the real part

c = i Mod 10 'Take the last number by use mod.

sum = a * a * a + b * b * b + c * c * c

'START CHECKING

If sum = i Then 'Checks if sum equals to i value

Label1.Caption = i & " is an Armstrong number"

Else

Label1.ForeColor = vbRed 'Change the font color of the ouput label to red!

Label1.Caption = i & " is not an Armstrong number"

End If

rusputin

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Dim i, a, b, c, sum As Integer 'Declare variable i,a,b,c,and sum

Label1.ForeColor = &HC000& 'Change the font color of the ouput label

i = Val(Text1.Text) 'Assign text1 value to i

a = i \ 100 'Divide the i value by 100 and take the real part

b = (i Mod 100) \ 10 'Use mod to remove the first number and divide by 10-> take the real part

c = i Mod 10 'Take the last number by use mod.

Sum = a * a * a + b * b * b + c * c * c

'START CHECKING

If sum = i Then 'Checks if sum equals to i value

Label1.Caption = i & " is an armstrong number"

Else

Label1.ForeColor = vbRed 'Change the font color of the ouput label to red!

Label1.Caption = i & " is not an armstrong number"

End If

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Armstrong number using function in vb6?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you get square root in Microsoft visual basic?

The function is Sqr() in VB6 and Math.Sqr() in .NET.


Solving transportation problem in Visual basic programming?

hi every body my name is mohamed i live in egypt i am a programer with vb6 i ca solve the transport problem using vb6 just keep in touch with me at my phone number 002 0106909294 thnks


What is difference between vb5 vb6?

VB6 is a more recent and more advanced version of visual basic.


How do you convert vb6 to dmg?

A .vb6 file is visual basic 6 source code, sometimes with it are .frm files that you would need. A .dmg is a Macintosh binary. you would have to find a program to compile the vb6 code to a Macintosh binary.


'Download Visual Studio 6 Or Visual Basic 6 In Free?

Studio consists of C#, VisualJ, etc. Visual Basic is the predefined function of the VB6 environment. if you want to code in VB strictly, download VB6, but if you want to use C#, etc. than use VS6. But by now, I recommend upgrading to VS2008


How can you execute a new line in VB6?

vbNewLine


Differences butween the vb6 asnd vbnet?

Please refer the following link, there you can find useful information about differences between VB6 and VB .NET


How do you make a cp trainer with free member?

use vb6


Free vb6 source code download for submission?

thanks


How can you make a vb6 project a web based project or how will you able to embed vb6 project or vb.net project into asp.net website?

you simply cant, unless you know how to upload exe's to the internet.


How can you print reports by vb6 using Crystal Report?

is : CrystalReport1.Reset CrystalReport1.ReportFileName="MyReport.rpt" CrystalReport1.Destination=(Printer) CrystalReport1.Action=6 CrystalReport1.DiscardSaveData=True


I am using the imgscan.ocx control in VB6 to scan the using the Hpscanjet2400 scanner.By default the scanner is set as Millions of colors option How I can change this option through VB 6 code.?

imgscan.SetScanCapability 100, 1 ' Noir et blanc