Hi ruben00000,
Here in this example i am making use of Regular Expression.
Please refer below code.
HTML
<asp:Label ID="lblMessage" runat="server"></asp:Label>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string textId = "CORESNR02-1Mech";
if (!string.IsNullOrEmpty(textId))
{
string id = Regex.Match(textId.Split('-')[1], @"\d+").Value;
lblMessage.Text = string.Format("{0}-{1}Mech", textId.Split('-')[0], (Convert.ToInt32(id) + 1));
}
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim textId As String = "CORESNR02-1Mech"
If Not String.IsNullOrEmpty(textId) Then
Dim id As String = Regex.Match(textId.Split("-"c)(1), "\d+").Value
lblMessage.Text = String.Format("{0}-{1}Mech", textId.Split("-"c)(0), (Convert.ToInt32(id) + 1))
End If
End If
End Sub
Screenshot