[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
Medium Priority
289 Views
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
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
• 4
• 2

LVL 75

Accepted Solution

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
``````
0

LVL 41

Expert Comment

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

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

LVL 1

Author Comment

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

ID: 37787167
You can click "Request Attention", but I'm not stressed about it. It's up to you  = )
0

LVL 1

Author Comment

ID: 37787275
Yea i did it :)
0

LVL 1

Author Closing Comment

ID: 37800875
thanks
0

Featured Post

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…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll