emi_sastra
asked on
Separating Variable From Operator
Hi,
I have a variable like :
strFormula = "abc+cde-fgh*1"
I want to separate them into 2 stringbuilder or other variable:
strVariable1 = abc,cde,fgh
strVariable2 = +,-,*
How could I do it?
Thank you.
I have a variable like :
strFormula = "abc+cde-fgh*1"
I want to separate them into 2 stringbuilder or other variable:
strVariable1 = abc,cde,fgh
strVariable2 = +,-,*
How could I do it?
Thank you.
ASKER
Hi pratima_mcs,
Is there any other simple way?
You know operator more than "+-*"
May be using regular expression?
Thank you.
Is there any other simple way?
You know operator more than "+-*"
May be using regular expression?
Thank you.
yu need to add
If (strFormula.Contains("+")) Then
strFormula = strFormula.Replace("+", ",")
If (strVariable2 = "") Then
strVariable2 = "+"
Else
strVariable2 = strVariable2 + "," + "+"
End If
End If
for each operator
If (strFormula.Contains("+"))
strFormula = strFormula.Replace("+", ",")
If (strVariable2 = "") Then
strVariable2 = "+"
Else
strVariable2 = strVariable2 + "," + "+"
End If
End If
for each operator
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Idle_Mind,
I think your code is what I am looking for.
Thank you very much for your help.
I think your code is what I am looking for.
Thank you very much for your help.
Open in new window