PC Review


Reply
Thread Tools Rate Thread

Backslash concatenation problem in VB.NET

 
 
Marina
Guest
Posts: n/a
 
      13th Feb 2007
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
(E-Mail Removed)

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VycnkgTW9vcm1hbg==?=
Guest
Posts: n/a
 
      13th Feb 2007
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
> (E-Mail Removed)
>
>

 
Reply With Quote
 
lord.zoltar@gmail.com
Guest
Posts: n/a
 
      13th Feb 2007
On Feb 13, 8:55 am, "Marina" <Marina...@gmail.com> 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
> mar...@nogacom.com


Have you tried
str = "\\" & variable

or maybe
str = Chr(92) & variable

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

 
Reply With Quote
 
Martin H.
Guest
Posts: n/a
 
      13th Feb 2007
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
> (E-Mail Removed)
>

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      13th Feb 2007
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" <(E-Mail Removed)> a écrit dans le message de news:
(E-Mail Removed)...
> 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
> (E-Mail Removed)
>



 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      13th Feb 2007
"Marina" <(E-Mail Removed)> schrieb:
> 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/>
 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      13th Feb 2007
>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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenation problem Charles W Davis Microsoft Excel Discussion 2 3rd Nov 2007 11:37 PM
Backslash concatination problem Marina Microsoft VB .NET 3 14th Feb 2007 06:06 AM
Regional and Language Options Korean Backslash Problem =?Utf-8?B?Qi5NaWx0Z2Vu?= Windows XP Help 0 3rd Feb 2006 05:49 PM
Concatenation problem Brad Allison Microsoft ADO .NET 1 19th Jul 2004 04:19 PM
Concatenation Problem Bob Rice Microsoft Access Form Coding 1 22nd Jul 2003 01:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 AM.