Variable - Super Easy question

Posted on 2005-03-08
Medium Priority
Last Modified: 2010-04-23
How can I add "\" to this variable ?

Dim rootpath As String = "C:\TEST\" & txtDirectory.Text & ""

so it would look like

Question by:JRockFL
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
  • Learn & ask questions
  • 3
LVL 12

Expert Comment

ID: 13489407
rootpath &= "\"   '(which is short-hand for rootpath = rootpath & "\")
LVL 12

Accepted Solution

S-Twilley earned 80 total points
ID: 13489416
you might want to expand it a bit more to this:

If Not rootpath.Endswith("\") then rootpath &= "\"   (checks to make sure it doesnt already end with \ ... if it doesn't it adds it)

Author Comment

ID: 13489478
I also need txtDirectory.Text

Dim rootpath As String = "C:\TEST\" & txtDirectory.Text & ""
LVL 12

Expert Comment

ID: 13489555
Those lines were meant to appear after that i.e.

Dim rootpath As String = "C:\TEST\" & txtDirectory.Text
If Not rootpath.Endswith("\") then rootpath &= "\"

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question