aspiringCoder
aspiringCoder

Reputation: 415

Can anyone tell me why this is entering a new line

I am concatenating a variable onto a path(string), i'm using a message box to display this for testing purposes, I can see that the variable is starting on a new line, which in turn when i try to open the file it doesn't recognize that the file exist...

Dim Path As String = "C:\Users\stefan\Desktop\Uni Work\Year 4\Projects\Project Selection\Project\Project\bin\Debug\"
    Shapetext = clickedShapes.Item(nextShape).Text.ToString.Substring(0, clickedShapes.Item(nextShape).Text.IndexOf(" "))

                        MsgBox(Path + Shapetext + ".txt")

can any1 help me out here?

Upvotes: 0

Views: 58

Answers (2)

Jared Mark
Jared Mark

Reputation: 156

On your final output string, you could always use something like

string.replace(vbCrLf, "")

or

string.replace(vbCr, "")

Upvotes: 0

Steve
Steve

Reputation: 216273

I suggest to:

  • Remove the MsgBox and replace with System.Diagnostics.Debug.Writeline(Path + Shapetext + ".txt")
  • Put a breakpoint on that line and run the debugger until the point.
  • Take note of the output in the output window.
  • Check if the file really exist in the output folder

At this point will be obvious what's wrong. Or file doesn't exist, or your string concat fails for some reason.

Upvotes: 2

Related Questions