Here is a hint on how to alternate between a positive and negative number.
Consider what happens to a number when you multiply it by -1 over and over again
1 * -1 = -1
-1 * -1 = 1
1 * -1 = -1
-1 * -1 = 1
See how the results alternate.
do that to a variable which is loaded with the value of 1 and use that value to multiply another number or variable by such as one you get from a For/Next loop. Of course you have to set the value of n=1 before you enter the loop , and withing the loop you multiply it by -1 at the and of each pass through the loop.
N=1
N * -1 = N (N now equals -1) , the next pass through the loop N * -1 = N is done again which make s N equal to a positive one. You can use then use N to multiply a copy of the loop variable so that it alternates between positive and negative for each pass through the loop.
You can also do this with an IF Else statement
IF N=1 then
N = -1
Else
N = 1
End IF
EDIT:
HINT.... The term you are looking to test is one of the fractions and NOT the total of those fractions.
example on the third pass through the loop the number 3 is used to make the fraction 1/3 which is 0.3333 This is the number that you will test against 0.0001 to see if you continue looping or not. The fourth pass results in 1/4 which is 0.25 etc... and so on until you generate a fraction that is less than 0.0001 . Also do not get the pos and neg value mixed up in your test so it the second pass you are subtracting or adding a negative -1/2 = -0.5 which is less than 0.0001 and would prematurely end your loop
ANSWER:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim denominator As Integer
Dim PosNeg_toggle As Integer
Dim total, term As Double
denominator = 1 ' initalize
PosNeg_toggle = 1
Do
'compute term
term = 1 / denominator ' this is always a positive result
'use the posneg_toggle to alternate between ADD and SUB (by adding a NEG)
total = total + (term * PosNeg_toggle)
'
'update variables for next pass through loop
denominator = denominator + 1 'increment
PosNeg_toggle = PosNeg_toggle * -1 ' change polarity of the number one
Loop While term > 0.0001
'display results
MsgBox("Total = " & total & " after " & denominator & " loops")
End Sub