Solved

Help manipulating my String

Posted on 2012-03-29
8
285 Views
Last Modified: 2012-04-03
Hello EE,

I have a string like this:

"=SUM(B1+C1+D1)"

What I need to do is each digit I need to increase by 1

so the string need to be at the end:

"=SUM(B2+C2+D2)"

another example:
"=SUM(B4+D5+H11)"

needed result:  "=SUM(B5+D6+H12)"

any idea ? (how to repert the digit then +1 on it etc..)
0
Comment
Question by:PhilippeRenaud
[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
  • 4
  • 2
8 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 37784197
Try:

Module Module1

    Sub Main()
        Dim input As String = "=SUM(B1+C1+D1)"
        Dim result As String = System.Text.RegularExpressions.Regex.Replace(input, "\d+", AddressOf ReplacementDelegate)
    End Sub

    Function ReplacementDelegate(ByVal m As System.Text.RegularExpressions.Match) As String
        Dim converted As Integer = Convert.ToInt32(m.Value)

        Return (converted + 1).ToString()
    End Function

End Module

Open in new window

0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 37784205
I would handle this by keeping the rows seperate:

int b=5;
int d=6;
int h=11;
String result;

result = print(b,d,h);

b++;
d++;
h++;

result = print(b,d,h);


string print(int b, int d, int h)
{
  return String.Format("=Sum(B{0}+D{1}+H{2}",b,d,h)
}
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 37787087
Hey kaufmed, related question :  


http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_27655660.html


how could we do both at the same time?  do you think its possible via the same Delegate maybe?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 37787095
by the way I clicked the wrong accepted answer. damn Im sorry, how can we fix this?
I went too fast
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37787167
You can click "Request Attention", but I'm not stressed about it. It's up to you  = )
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 37787275
Yea i did it :)
0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 37800875
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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