How to find sum of numbers from 1 to 100 in visual basic 6.0

Display sum of numbers from 1 to 100 in visual basic 6

Are you looking for a solution for a visual basic program that will display the sum of two numbers? Then don’t worry because here in this post you can get the proper solution for how to find the sum of numbers from 1 to 100 in visual basic 6. As well as you can find the sum from 1 to 1000. By using this program you can find the sum between any two numbers. This program is different from the calculating sum of the numbers in the previous post we have already seen that point, if you want to see that post then check here. How to calculate sum of digits of given number in vb6.

For creating this program I have used here visual basic for loop. Here in this program, you can directly enter the numbers manually in the textbox as well as you can set the default value in the source code. If you are a college student then you know that these type’s visual basic programs are very confusing. And due to that most of the students can’t write a code in visual basic to find the sum of numbers from 1 to 10 therefore here I have tried to solve your problem.

How-to-find-sum-of-numbers-from-1-to-100-in-visual-basic-6

If you are worried about how to write coding for this program then relax and don’t worry because below I have given very easy steps to create the visual basic program that will help you find the sum of numbers from 1 to 100. Before start to the program, I told you this program is only for beginners if you are an advanced programmer then you know how to write a visual basic 6.0 program that displays the sum of numbers from 1 to 100. So, If you are an advanced programmer then skip this post.

Steps for writing a program to find the sum of numbers from 1 to 100

  1. Open Microsoft visual basic 6.0
  2. Create a new form
  3. Draw two textboxes, two buttons, and four labels, in that textbox for input and labels for displaying the sum of numbers.
  4. After that write the below source code on the ‘Display Sum’ Button and the ‘Reset’ Button.
  5. Then run the program.

Source code for a vb program that displays the sum of numbers from 1 to 100

Private Sub btnsum_Click()

Dim num, calcsum As Double

 

For num = Text1.Text To Text2.Text

calcsum = calcsum + num

Next num

Label1.Caption = calcsum

End Sub

 

Private Sub btnreset_Click()

Text1.Text = ""

Text2.Text = ""

Label1.Caption = ""

End Sub


write-a-code-in-visual-basic-to-find-sum-of-between-two-numbers

What is the working flow of this visual basic program?

If your program is executed properly then I think you understood the working of this program and maybe you get the best logical idea for the program that displays the sum of numbers from 1 to 100. In the front end, I have given two textboxes in that textbox you can enter the numbers which are you want to display the sum, then click on the ‘Display Sum’ command button after that the sum of between entered numbers will display in the given label. As well as you can enter numbers again by pressing the reset button.

When you enter the numbers in the textbox then remember that you should enter the first number that is smaller than the second number otherwise the sum will display zero. If you want to only display the numbers from 1 to 100 then you can directly set the default value in for loop. But here I have set the textbox in for loop due to you can enter the numbers manually.

How-to-write-a-visual-basic-program-that-displays-the-sum-of-numbers-from-1-to-50

This is a very basic example of for loop, If you want to practice the visual basic for loop properly then you can refer this post. I hope you understood the working flow of this program, this is very simple solution for visual basic programs example. Here we are always try to provide an easy visual basic programs with codes and output. If you are interested in visual basic programming language then you can refer allvbprograms blog.

Why do we need to write the vb6 program to find the sum of numbers from 1 to 100

There are no more needs for this program but if you are a college student then you know the needs of this program because most of the time these type’s questions are asked in exams. So, you must practice and prepare for these types of questions. This program is very helpful at that time when you are practicing the visual basic for a loop because in this program I have used the for loop to create this program to find the sum of numbers from 1 to 10 or display the sum from 1 to 100 in visual basic 6.0.

Sometime in college practical asked the question for write a program to print 1 to 10 using for loop in visual basic therefore you need to practice this program. If you are looking for the solution for writing a vb program to print even numbers 1 to 50 then I told you, here I have given the solution for displaying the sum of given numbers. If you want a solution for displaying the even numbers from 1 to 50 then you can comment to me I will give you a solution for your problem.

write-a-program-to-print-1-to-1000-using-for-loop-in-visual-basic-6

I hope you like this post and properly understood how to find the sum of numbers from 1 to 100 in visual basic 6. If you want the solution for any types of examples of visual basic programs then you can directly comment to me or you can send your problem through the contact form.

Conclusion:

In this program, you can learn how to write a visual basic 6.0 program that displays the sum of numbers from 1 to 100. In the program, you can also enter the numbers manually. If you want to practice the visual basic for loop then you can try this program. Here for creating the program that prints the sum of in between two numbers you can get the easy source coding with proper explanations.


Post a Comment

0 Comments