Visual Basic (VB) Question:
Download Questions PDF

Hi, sorry but i have a simple question ! i have a string like "2^5+2*5^2-1" in a textbox and i want to have the result of this string in another textbox. but i cant get the answer!
i am new and i want to have a function like :
f(x) = x^5+2*x^2-1 and then i can calculate f(i) for example for i = 0 to 100
please help?

Answer:

I believe that in VB6, there is no facility to calculate maths formula from string. So you need to create a function or your own logic to implement such a calculation.
Here is the code for above question. You can call that function with passing your number.
Function Calc(ByVal intNumber As Integer) As Double
Dim dblResult As Double
dblResult = (intNumber ^ 5) + (2 * (intNumber ^ 2)) - 1
Calc = dblResult
End Function
I hope it helps.

Download Visual Basic (VB) Interview Questions And Answers PDF

Previous QuestionNext Question
DSN Less Connection in VB?How do you register a component?