I'm trying to remove the middle portion ('G0G90E1' and 'M3S3000') of a string. However, the length from the start to the end will vary, and the number after the 'S' will vary, too (Ex: 'S500', 'S10000', etc.). I'm trying to format this string, which is in ShowContentsOfFile.Text:
'G0G90E1X0Y0M3S3000
'X0Y0
'X1Y1
To this, BUT, only for the copies (which are show in 'E2' and below), which is what the For, Next loop is doing, so, for example, it'll look like this, when I make, say, 5 parts:
'G0G90E1X0Y0M3S3000
'X0Y0
'X1Y1
'E2X0Y0
'X0Y0
'X1Y1
'E3X0Y0
'X0Y0
'X1Y1
'E4X0Y0
'X0Y0
'X1Y1
'E5X0Y0
'X0Y0
'X1Y1
Unfortunately, it also gets rid of the lines below 'E1':
'X0Y0
'X1Y1
Here's my code:
If NumberOfParts.Text = NumberOfParts.Text Then
Dim CopySpecificText As String = ShowContentsOfFile.Text
Dim Start As Integer = CopySpecificText.IndexOf("E1")
Dim Finish As Integer = CopySpecificText.IndexOf("M")
Dim DynamicString As String
Dim x As Integer
CopySpecificText = CopySpecificText.Replace("G0G90E1", "").Substring(Start, Finish - Start).Trim
My.Computer.Clipboard.SetText(CopySpecificText)
For x = 1 To NumberOfParts.Text - 1
DynamicString = "E" & x + 1
ShowContentsOfFile.Text += Environment.NewLine & DynamicString & Clipboard.GetText
Next x
End If