Question

In: Computer Science

Visual Basic Question : Sum = 1 + 1/2 + 1/3 + 1/4 + ....... A...

Visual Basic Question :

Sum = 1 + 1/2 + 1/3 + 1/4 + .......

A project which allows the user to enter a number in the Textbox1 and which indicates the number of terms on the Label

e.g. I enter 10 (sum) in the Textbox1 and Label1 indicates 12367 (terms)

I have tried a few days but it does not work... thanks for your help!

dim i, t as integer

for i = 1 to t-1

textbox1 = textbox1 + 1/i

next

Label1 = t

Solutions

Expert Solution

NOTE :

HERE IN THE QUESTION EXCEPT TEXTBOX AND LABEL NO OTHER OBJECT FROM TOOLBOX ARE MENTIONED, SO HERE ONLY TEXTBOX AND LABEL ARE USED.

SO, HERE THE TEXT_CHANGE PROPERTY OF TEXTBOX IS USED. MEANS WHEN IN THE TEXTBOX THE SUM VALUE WILL BE PUT, THE CORRESPONDING NUMBER OF TERMS WILL BE SHOWN IN LABEL.

HERE THE PROGRAM IS DONE WITH VISUAL BASIC IN VISUAL STUDIO 2008 PLATFORM.

PROGRAM  

Public Class Form1
Dim s As Integer
'initialize variable term as 1
Dim term As Long = 1
'initialize variable c as 0
Dim c As Integer = 0
'initialize variable sum as 0
Dim sum As Double = 0.0
' here number terms will be shown on label when sum is put in textbox
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
' s store the value put in textbox1
s = Val(TextBox1.Text)
' the loop will continue until sum is less than s
While (sum < s)
' calculate sum of terms
sum = sum + 1 / term
' increment number of terms
term = term + 1
End While
' print number of terms in label
Label1.Text = term - 1
End Sub
End Class

SCREEN SHOT

OUTPUT


Related Solutions

Modify the sum_thread.cpp program to compute sum = 1 + 1/2 + 1/3 + 1/4 +...
Modify the sum_thread.cpp program to compute sum = 1 + 1/2 + 1/3 + 1/4 + … 1/n. Let’s estimate natural using n = 20. sum_thread.cpp #include <chrono> #include <iostream> #include <mutex> #include <random> #include <utility> #include <vector> #include <thread> using namespace std; constexpr long long size= 1000000; mutex myMutex; void sumUp(unsigned long long& sum, const vector<int>& val, unsigned long long beg, unsigned long long end){ long long localSum = 0; for (auto it= beg; it < end; ++it){ localSum+=...
1.- Explain what a class is in Visual Basic. 2.- Explain what a method is in...
1.- Explain what a class is in Visual Basic. 2.- Explain what a method is in Visual Basic. 3.- What is the average formula? 4.- What is the variance formula? 5.- What is the standard deviation formula?
1. What is the difference between Write and WriteLine in Visual Basic? 2. Can there be...
1. What is the difference between Write and WriteLine in Visual Basic? 2. Can there be more than one variable in a Write or WriteLine? Do they have to be all variables of the same type? Show it by modifying your program. Submit the modified and duly documented program in Visual Basic. 3. Explain the possible assignments of values to numerical variables of different primitive types: integer assigned to integer, integer assigned to real, real assigned to integer and real...
SE-FamilySize 1 1 4 3 2 4 2 3 4 2 4 1 4 2 2...
SE-FamilySize 1 1 4 3 2 4 2 3 4 2 4 1 4 2 2 4 5 4 5 4 4 2 4 3 1 2 3 5 5 5 Make a confidence interval. Be sure you show all the steps you took. Include a screen shot of any applet you used in your calculations. 2. Choose a confidence level (1 – α). 3. What is xbar? 4. What is s? 5. What is t? (Show a screen shot...
Visual Basic Your first job is to create a visual basic project that will display the...
Visual Basic Your first job is to create a visual basic project that will display the name and telephone number for the contact person for the customer relations, marketing, order processing, and shipping departments. Include a button for each department. When the user clicks on the button for a department the program(in code for specific button will display the name and telephone number for the contact person in two labels. The same two labels will be used for each department...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
-Write a program in C++: • to find the sum of the series 1! /1+2! /2+3!...
-Write a program in C++: • to find the sum of the series 1! /1+2! /2+3! /3+4! /4+5! /5 using the function1, • to convert decimal number to binary number using the function2, • to check whether a number is a prime number or not using the function3, • to check whether two given strings are an anagram using the function4. important must do in (Multi-Filing) of c++
The following page-reference string: 1, 2, 4, 3, 2, 5, 4, 2, 4, 2, 1, 3,...
The following page-reference string: 1, 2, 4, 3, 2, 5, 4, 2, 4, 2, 1, 3, 2, 3, 1, 3, 6, 1, 6, 4. Main memory with 3 frames of 1 kilobyte available and they are all initially empty. Complete a figure, similar to Figure 8.14(in the slides or textbook), showing the frame allocation for each of the following page replacement policies: a. Optimal b. Least recently used c. First-in-first-out Then, find the relative performance of each policy with respect...
.  There are 4 basic mechanisms that control development: (1) Induction; (2) differential gene expression; (3) cell...
.  There are 4 basic mechanisms that control development: (1) Induction; (2) differential gene expression; (3) cell migration; (4) cytoplasmic determinants. Write  an essay describing how each mechanism  is involved in playing out the developmental program.  In your answer first define each mechanism and then describe two examples taken from lecture that illustrate how that method is used in development.
Question 1 The probability that a teacher will see 0, 1, 2, 3, or 4 students...
Question 1 The probability that a teacher will see 0, 1, 2, 3, or 4 students (a)        What is the probability that the teacher see 3 students?                                               (b)       What is the probability that the number of students the teacher will see is between 1 and 3 inclusive?          (c)        What is the expected number of students that the teacher will see? (d)       What is the standard deviation? Question 2 The probability that a house in an urban area...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT