473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Backslash concatenation problem in VB.NET

Hi,

I'm trying to concatenate: "\" & variable, where variable is some
string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".

I've tried almost everything.
Does anyone has an idea.

Thanks a lot, Marina
ma****@nogacom.com

Feb 13 '07 #1
6 12098
Marina,

Let's see the code you are trying.

Kerry Moorman
"Marina" wrote:
Hi,

I'm trying to concatenate: "\" & variable, where variable is some
string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".

I've tried almost everything.
Does anyone has an idea.

Thanks a lot, Marina
ma****@nogacom.com

Feb 13 '07 #2
On Feb 13, 8:55 am, "Marina" <Marina...@gmail.comwrote:
Hi,

I'm trying to concatenate: "\" & variable, where variable is some
string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".

I've tried almost everything.
Does anyone has an idea.

Thanks a lot, Marina
mar...@nogacom.com
Have you tried
str = "\\" & variable

or maybe
str = Chr(92) & variable

....I'm not sure if Chr is still valid, though.

Feb 13 '07 #3
Hello Marina,

I wonder, is "variable" the result of a Strings.Mid or Strings.Right
operation? In that case it could be that you cut one character too far
to the left.

Example:

Private Sub Test()
Dim Directory As String ="C:\Windows"
Dim Variable As String
Variable = Strings.Right(Directory,8)
MsgBox("\" & Variable)
End Sub

In this example you would receive "\\Windows", because you cut the
string for "variable" with 8 instead of 7 digits. Maybe it is a similar
issue with your code?

Best regards,

Martin

Marina wrote:
Hi,

I'm trying to concatenate: "\" & variable, where variable is some
string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".

I've tried almost everything.
Does anyone has an idea.

Thanks a lot, Marina
ma****@nogacom.com
Feb 13 '07 #4
Additionnaly to other responses and if this is for path handling you have
some methods for this in System.IO.Path.

For example "Combine" will add the separator if needed...

---
Patrice

"Marina" <Ma*******@gmail.coma écrit dans le message de news:
11*********************@j27g2000cwj.googlegroups.c om...
Hi,

I'm trying to concatenate: "\" & variable, where variable is some
string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".

I've tried almost everything.
Does anyone has an idea.

Thanks a lot, Marina
ma****@nogacom.com

Feb 13 '07 #5
"Marina" <Ma*******@gmail.comschrieb:
I'm trying to concatenate: "\" & variable, where variable is some
string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".
\\\
Dim s As String = "Test"
Dim t As String = "\" & s
MsgBox(t)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Feb 13 '07 #6
>I'm trying to concatenate: "\" & variable, where variable is some
>string, but VB is making it to be "\\variable".
for example if variable is "Test", vb is making it to be "\\Test"
instead of "\Test".
You're not viewing the string in the debugger in a C# project, are
you? In C# (and other C-style languages) \\ represents a single \
since \ is an escape character.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Feb 13 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jonas Galvez | last post by:
Is it true that joining the string elements of a list is faster than concatenating them via the '+' operator? "".join() vs 'a'+'b'+'c' If so, can anyone explain why?
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
2
by: John Dann | last post by:
I guess there must be some convention or Windows specification for whether the backslash immediately preceding the file name in a full path string to a file is formally part of the path string or...
34
by: Larry Hastings | last post by:
This is such a long posting that I've broken it out into sections. Note that while developing this patch I discovered a Subtle Bug in CPython, which I have discussed in its own section below. ...
3
by: Stef Mientki | last post by:
It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code)...
2
by: Tobiah | last post by:
>>"'" "'" "'" "\\'" "\\'" This is quite different than any other language that I am used to. Normally, a double backslash takes away the special meaning of the last backslash, and so you...
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
4
by: Razzbar | last post by:
I'm working on a bookmarklet that grabs information from a page and submits it to a server. Yet another social bookmarking application. I'm having trouble with page titles that include an...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
4
nithinpes
by: nithinpes | last post by:
I will boil down my exact requirement to this: I should print out lines that do not contain semi-colon, backslash and closing parentheses. The following one -liner works fine. perl -ne "unless(//)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.