|
-
Nov 17th, 2011, 11:58 PM
#1
Thread Starter
New Member
Noob Question - getting the sum of a string of numbers?
Hello everybody,
I am a beginner in the world of VB - although i do have a medium knowledge of Python, HTML/CSS.
I am working on my first basic program.
a simple calculator.
Buttons representing numbers 0-9
Buttons with + - x / =
and a clear button.
So what ive done is created a string, and when the user hits the button, it adds that value to the string (hit buton 4, it adds a 4, hit the minus, it adds a -)
i need a "function" that grabs that string, uses logical math on it, to determine the answer. I know in Python you can use:
Eval(STRING NAME)
is there an equivelant for VB?
any help, will be greatly appreciated!! 
Gobble45
-
Nov 18th, 2011, 12:09 AM
#2
Re: Noob Question - getting the sum of a string of numbers?
there's no exact equivalent, but you can use this. notice the parentheses to establish operator precedence:
vb Code:
Dim dt As New DataTable
Dim answer As Integer = CInt(dt.Compute("((1 + 2 + 3) * 5) / 3", Nothing))
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|