How to Convert Escape Characters from C# to VB.NET 
Author Message
 How to Convert Escape Characters from C# to VB.NET

I have a character escape sequence

\"  which produces a quote, "

However, how would I convert to this and all of them to "" for VB.NET

When I do a simple replace for

    string test = "\""
    test = test.Replace(\\\" , "\"\"|)

it still sees it as a quote, "

Not as a \"    ......thus it's not replaced.

In other words, how does one convert escape sequences in C# to VB.NET?

Thanks.



Fri, 23 Sep 2005 03:54:08 GMT  
 How to Convert Escape Characters from C# to VB.NET
\" should convert to " in vb. The code you posted isn't vb code, in fact, it wouldn't compile under any language; so I'm not sure what you were asking about there... but as far as conversion goes, you must do it on a per-character basis:

\" = ""
\n = " & vbCrLf & "
... ect ...

To program the conversion, you would do something like this:

Dim strTest as String

' set strTest = \"
strTest = "\"""

' replace \" with ""
strTest = strTest.Replace("\""", """""")

That's all you have to do...

HTH,
Jeremy

Quote:

> I have a character escape sequence

> \"  which produces a quote, "

> However, how would I convert to this and all of them to "" for VB.NET

> When I do a simple replace for

>     string test = "\""
>     test = test.Replace(\\\" , "\"\"|)

> it still sees it as a quote, "

> Not as a \"    ......thus it's not replaced.

> In other words, how does one convert escape sequences in C# to VB.NET?

> Thanks.



Fri, 23 Sep 2005 06:44:11 GMT  
 How to Convert Escape Characters from C# to VB.NET
Thanks, but this is from C# to VB.NET .....and USING C# to do the convert...

You see C# sees

\" as just a "......so it's not recognizing the \" together.....it's also
really really tough to get at when the \" is are together like that....

I can't even recognize it on a per character basis......I was trying to
first search for a " via .IndexOf and then do a back track -1 to see if
there is \

BUT it still sees is it as a "

All this is in C#

I am not sure how to attack this problem of looking for an escape sequence
in C#


\" should convert to " in vb. The code you posted isn't vb code, in fact, it
wouldn't compile under any language; so I'm not sure what you were asking
about there... but as far as conversion goes, you must do it on a
per-character basis:

\" = ""
\n = " & vbCrLf & "
... ect ...

To program the conversion, you would do something like this:

Dim strTest as String

' set strTest = \"
strTest = "\"""

' replace \" with ""
strTest = strTest.Replace("\""", """""")

That's all you have to do...

HTH,
Jeremy


Quote:
> I have a character escape sequence

> \"  which produces a quote, "

> However, how would I convert to this and all of them to "" for VB.NET

> When I do a simple replace for

>     string test = "\""
>     test = test.Replace(\\\" , "\"\"|)

> it still sees it as a quote, "

> Not as a \"    ......thus it's not replaced.

> In other words, how does one convert escape sequences in C# to VB.NET?

> Thanks.



Fri, 23 Sep 2005 16:30:33 GMT  
 How to Convert Escape Characters from C# to VB.NET
I would start by posting your question in the C# group, since it's a question about C# code.
Quote:

> Thanks, but this is from C# to VB.NET .....and USING C# to do the convert...

> You see C# sees

> \" as just a "......so it's not recognizing the \" together.....it's also
> really really tough to get at when the \" is are together like that....

> I can't even recognize it on a per character basis......I was trying to
> first search for a " via .IndexOf and then do a back track -1 to see if
> there is \

> BUT it still sees is it as a "

> All this is in C#

> I am not sure how to attack this problem of looking for an escape sequence
> in C#



> \" should convert to " in vb. The code you posted isn't vb code, in fact, it
> wouldn't compile under any language; so I'm not sure what you were asking
> about there... but as far as conversion goes, you must do it on a
> per-character basis:

> \" = ""
> \n = " & vbCrLf & "
> ... ect ...

> To program the conversion, you would do something like this:

> Dim strTest as String

> ' set strTest = \"
> strTest = "\"""

> ' replace \" with ""
> strTest = strTest.Replace("\""", """""")

> That's all you have to do...

> HTH,
> Jeremy



> > I have a character escape sequence

> > \"  which produces a quote, "

> > However, how would I convert to this and all of them to "" for VB.NET

> > When I do a simple replace for

> >     string test = "\""
> >     test = test.Replace(\\\" , "\"\"|)

> > it still sees it as a quote, "

> > Not as a \"    ......thus it's not replaced.

> > In other words, how does one convert escape sequences in C# to VB.NET?

> > Thanks.



Sat, 24 Sep 2005 03:09:39 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Convert VB.Net to C#, convert C# to VB.Net

2. Tell me you experience in convert code from VB 6 to VB.NET or C#

3. Code Convert from C# to VB.Net

4. Convert VB.NET code to C#?

5. Convert C# to VB.NET

6. IntelliSense in VS.NET (C# versus VB.NET)

7. Escaping Characters in VB

8. Escape sequence in VB Strings (and Characters)

9. escape characters in VB?

10. escaping characters in VB?

11. VB.NET: Steps for Converting a Windows .NET Application to a Web .NET Application

12. VB to C# or C# to VB convertor

 

 
Powered by phpBB® Forum Software