N
Novice
Hey all, I apologize in advanced if I have posted this to the wrong group -
but I'm not sure of where this should be posted.
I have some text in a text file in Visual Studio (not that it is relevant
but I'm developing a C# application). I would like to add a few characters
at the end of each line in this text file.
Right now I have this code:
Sub TemporaryMacro()
Dim Counter
Do While Counter < 10
Counter = Counter + 1
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.Text = Counter & ", '"
DTE.ActiveDocument.Selection.EndOfLine()
'Need to back up because there is sometimes a space at end of line
DTE.ActiveDocument.Selection.CharLeft()
DTE.ActiveDocument.Selection.Text = "')"
DTE.ActiveDocument.Selection.LineDown()
DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
Loop
End Sub
However, sometimes at the end of the line there is a space - I want to
ensure that the characters I add occur before the space characters at the end
of the line.
I tried using some code like this:
If (DTE.ActiveDocument.Selection.Text = " ") Then
MsgBox("found a space character")
Else
DTE.ActiveDocument.Selection.CharRight()
End If
But the above conditional never finds the space character.
Any suggestions?
Thanks,
Novice
PS The input is something like this:
Executive
Senior Executive
President
Secretary
Administrative Assistant
And the output will have some text before and after the above text:
some text 1, 'Executive')
some text 2, 'Senior Executive')
some text 3, 'President')
some text 4, 'Secretary')
some text 5, 'Administrative Assistant')
notice that there are no spaces after each of the above titles (that is what
I'm trying to prevent).
but I'm not sure of where this should be posted.
I have some text in a text file in Visual Studio (not that it is relevant
but I'm developing a C# application). I would like to add a few characters
at the end of each line in this text file.
Right now I have this code:
Sub TemporaryMacro()
Dim Counter
Do While Counter < 10
Counter = Counter + 1
DTE.ActiveDocument.Selection.Paste()
DTE.ActiveDocument.Selection.Text = Counter & ", '"
DTE.ActiveDocument.Selection.EndOfLine()
'Need to back up because there is sometimes a space at end of line
DTE.ActiveDocument.Selection.CharLeft()
DTE.ActiveDocument.Selection.Text = "')"
DTE.ActiveDocument.Selection.LineDown()
DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
Loop
End Sub
However, sometimes at the end of the line there is a space - I want to
ensure that the characters I add occur before the space characters at the end
of the line.
I tried using some code like this:
If (DTE.ActiveDocument.Selection.Text = " ") Then
MsgBox("found a space character")
Else
DTE.ActiveDocument.Selection.CharRight()
End If
But the above conditional never finds the space character.
Any suggestions?
Thanks,
Novice
PS The input is something like this:
Executive
Senior Executive
President
Secretary
Administrative Assistant
And the output will have some text before and after the above text:
some text 1, 'Executive')
some text 2, 'Senior Executive')
some text 3, 'President')
some text 4, 'Secretary')
some text 5, 'Administrative Assistant')
notice that there are no spaces after each of the above titles (that is what
I'm trying to prevent).