LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Solve operators within a string...split?

I have a string that contains math problems with numbers and operators. I
need to assign the solution to a variable. See examples below.

My first thought was to use split with "+" as my delimiter. Worked great!
Problem is that the string can have any combination of +, -, *, and /
operators or no operators at all.

Anyone have a suggestion?

Examples:

String ; Result
"15" ; 15
"10+5" ; 15
"20-5" ; 15
"10+7-2" ; 15
"30/3+5" ; 15
"-5+20" ; 15

Notice the minus sign in the last example. If a minus sign is the first
character then the first number is negative.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula Help - Split capital letters from first part of string Beverly-Texas Excel Discussion (Misc queries) 2 February 4th 10 09:06 PM
Split text string using mid-search? DubboPete Excel Discussion (Misc queries) 3 January 28th 10 12:37 AM
extract text from string, leaving numbers and operators CEG Excel Discussion (Misc queries) 13 March 4th 09 11:31 PM
split string based on a SET of words [email protected] Excel Discussion (Misc queries) 8 August 3rd 07 03:09 AM
Excel 2000 VBA - Using Split() with no Lelimiter in string sub_pop[_8_] Excel Programming 4 July 29th 04 10:32 PM


All times are GMT +1. The time now is 12:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"