Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Create string by calculating other strings

Posted on 2011-03-15
4
Medium Priority
?
316 Views
Last Modified: 2012-05-11
I have two strings.
strValue = "200.50"
strCalculation = "/5/4"

I need to get the value of strValue and strCalculation...
i.e: 200.50/5/4

Is this possible?
0
Comment
Question by:antonioking
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 35139392
In Excel VBA, yes - you can use:
Evaluate(strvalue & strcalculation)

Open in new window

0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35139401
MsgBox Evaluate(strValue & strCalculation)

Open in new window

0
 
LVL 19

Expert Comment

by:Arno Koster
ID: 35139475
so you need the value of the expression 200.50 / 5 / 4 = 200.50 / 20 = 10.025 ?

to get the value of strValue, use : val(strValue)
to perform the calculations however depends on how far you would want to go. building a complete mathematic parser will take you a lot effort.
When the calculations are simple (eg. only dividing or multiplying), it can be done like :
strValue = "200.50"
strCalculation = "/5/4"

numerator = Val(strValue)
While Left(strCalculation, 1) = "/"
    pos = InStr(Mid(strCalculation, 2), "/")
    If pos > 0 Then
        denominator = Val(Mid(strCalculation, 2, pos - 1))
    Else
        denominator = Val(Mid(strCalculation, 2))
    End If
    numerator = numerator / denominator
    If pos > 0 Then
        strCalculation = Mid(strCalculation, pos + 1)
    Else
        strCalculation = ""
    End If
Wend
Result = numerator

Open in new window

0
 
LVL 19

Expert Comment

by:Arno Koster
ID: 35139483
hrm,

never mind ;-)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question