[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help manipulating my String

Posted on 2012-03-29
8
Medium Priority
?
290 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
  • 4
  • 2
7 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 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 41

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Loops Section Overview
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

873 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