[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Help manipulating my String

Posted on 2012-03-29
8
Medium Priority
?
289 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 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

656 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