B
Brian VanPelt
I am not a very experienced VB user, but I was trying to make a form
that a user could input a formula for summation.
For example, I would like the user to input the beginning and end
values of a counter, and also have the user input the formula to be
added up.
More explicitly, suppose a user wants to add up
1 + 1/2 + 1/3 + 1/4 + ... + 1/100
Thus, the user would enter 1 as the start value and 100 for the end
value and this user would also enter the formula 1/n, in a text box,
as the summation formula (note that n would be a variable).
Suppose a user wants to find the sum of
1/2^2 + 1/3^2 + 1/4^2 + ... +1/100^2.
Then, the user would input 2 as the start value, 1000 as the end value
and also input the formula 1/n^2.
VB doesn't seem to like having the user enter the formula. I have
tried something like this
Dim n as integer
Dim s as double
s = 0
For n = start.text to final.text
s = s + input.text
Next
Print s
I have also tried to convert input.text to double (inside of the For
loop), and VB throws up an unhandled exception.
Since I am not very well versed in VB, I am not certain that I have
explained the situation in the best way. So, any help or pointers
would be very much appreciated.
Thanks,
Brian
that a user could input a formula for summation.
For example, I would like the user to input the beginning and end
values of a counter, and also have the user input the formula to be
added up.
More explicitly, suppose a user wants to add up
1 + 1/2 + 1/3 + 1/4 + ... + 1/100
Thus, the user would enter 1 as the start value and 100 for the end
value and this user would also enter the formula 1/n, in a text box,
as the summation formula (note that n would be a variable).
Suppose a user wants to find the sum of
1/2^2 + 1/3^2 + 1/4^2 + ... +1/100^2.
Then, the user would input 2 as the start value, 1000 as the end value
and also input the formula 1/n^2.
VB doesn't seem to like having the user enter the formula. I have
tried something like this
Dim n as integer
Dim s as double
s = 0
For n = start.text to final.text
s = s + input.text
Next
Print s
I have also tried to convert input.text to double (inside of the For
loop), and VB throws up an unhandled exception.
Since I am not very well versed in VB, I am not certain that I have
explained the situation in the best way. So, any help or pointers
would be very much appreciated.
Thanks,
Brian