468,463 Members | 2,034 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,463 developers. It's quick & easy.

Replacement for StrReverse Function

I've removed the Microsoft.VisualBasic import from my VB.Net project and am
in the process of replacing the vb6 compatible calls with native .Net i.e.
system.datetime.now instead of Now, variable Is Nothing instead of
IsNothing(variable) etc. I cannot find a native .Net replacement for the
StrReverse function. Is anyone familiar with a quick fix?
Nov 20 '05 #1
22 3887
Hi John,

Here is the visualbasic.namespace.

http://msdn.microsoft.com/library/de...rykeywords.asp

Do not mix this up with the visualbasic compatible namespace

This is a full part of dotNet.

Cor
Nov 20 '05 #2
In article <uJ**************@tk2msftngp13.phx.gbl>, John Cobb wrote:
I've removed the Microsoft.VisualBasic import from my VB.Net project and am
in the process of replacing the vb6 compatible calls with native .Net i.e.
system.datetime.now instead of Now, variable Is Nothing instead of
IsNothing(variable) etc. I cannot find a native .Net replacement for the
StrReverse function. Is anyone familiar with a quick fix?


How 'bout something like this :)

Private Function ReverseString(ByVal input As String) As String
If Not IsNothing(input) Then
Dim chars() As Char = input.ToCharArray()
Array.Reverse(chars)
Return New String(chars)
End If
End Function

--
Tom Shelton [MVP]
Nov 20 '05 #3
Hi Tom,
If Not IsNothing(input) Then


Especialy that IsNothing(input) that is real the one.

:-))

Cor


Nov 20 '05 #4
Hi Cor,
At the Develop Mentor Architect Training event hosted by Microsoft in the
Dallas office this week the instructor was showing how some functions like
these are wrapped by .Net to allow backwards compatibility. If you use
ildasm to look at the intermediate language of your assembly you can see
where things like OnError Goto etc. generate more IL than if you use the
native .Net functionality. It was suggested there to remove the
Microsoft.VisualBasic import and replace functions like Asc, Left$,
StrReverse, etc. with true .Net commands to generate leaner, tighter code.
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi John,

Here is the visualbasic.namespace.

http://msdn.microsoft.com/library/de...rykeywords.asp
Do not mix this up with the visualbasic compatible namespace

This is a full part of dotNet.

Cor

Nov 20 '05 #5
Tom,
Yes, that will work and I'll probably use something like that if there's not
a native .Net function already available. I was just curious if this
functionality was already part of the framework.

"Tom Shelton" <to*@mtogden.com> wrote in message
news:OV**************@TK2MSFTNGP11.phx.gbl...
In article <uJ**************@tk2msftngp13.phx.gbl>, John Cobb wrote:
I've removed the Microsoft.VisualBasic import from my VB.Net project and am in the process of replacing the vb6 compatible calls with native .Net i.e. system.datetime.now instead of Now, variable Is Nothing instead of
IsNothing(variable) etc. I cannot find a native .Net replacement for the StrReverse function. Is anyone familiar with a quick fix?


How 'bout something like this :)

Private Function ReverseString(ByVal input As String) As String
If Not IsNothing(input) Then
Dim chars() As Char = input.ToCharArray()
Array.Reverse(chars)
Return New String(chars)
End If
End Function

--
Tom Shelton [MVP]

Nov 20 '05 #6
In article <O$**************@TK2MSFTNGP09.phx.gbl>, Cor Ligthert wrote:
Hi Tom,
If Not IsNothing(input) Then


Especialy that IsNothing(input) that is real the one.

:-))

Cor


Huh? I'm not following...

--
Tom Shelton [MVP]
Nov 20 '05 #7
In article <O$**************@TK2MSFTNGP09.phx.gbl>, Cor Ligthert wrote:
Hi Tom,
If Not IsNothing(input) Then


Especialy that IsNothing(input) that is real the one.

:-))

Cor


Actually, I think I would change the test to:

If Not IsNothing(input) AndAlso input.Length <> 0 Then
...
End If

--
Tom Shelton [MVP]
Nov 20 '05 #8
* "John Cobb" <jo*******@acxiom.com> scripsit:
I've removed the Microsoft.VisualBasic import from my VB.Net project and am
Are you ill?
in the process of replacing the vb6 compatible calls with native .Net i.e.
'Microsoft.VisualBasic' (in "Microsoft.VisualBasic.dll") doesn't include
"VB6 compatible calls", it simply includes VB.NET methods. The
compatibility functions are in the
'Microsoft.VisualBasic.Compatibility.VB6' namespace (in
"Microsoft.VisualBasic.Compatibility.dll").
system.datetime.now instead of Now, variable Is Nothing instead of
IsNothing(variable) etc.
'IsNothing' is not the same as 'Is Nothing'!
I cannot find a native .Net replacement for the
StrReverse function. Is anyone familiar with a quick fix?


I don't think that there is one. I would continue using VB.NET's
'StrReverse' function.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9
In article <uk*************@TK2MSFTNGP09.phx.gbl>, John Cobb wrote:
Tom,
Yes, that will work and I'll probably use something like that if there's not
a native .Net function already available. I was just curious if this
functionality was already part of the framework.


Other the the VB.NET StrReverse function - then I'm not aware of it.
Unless it's lurking in System.Text.RegularExpressions - and I generally
avoid that namespace since the implementation is so slow...

--
Tom Shelton [MVP]
Nov 20 '05 #10
* Tom Shelton <to*@mtogden.com> scripsit:
In article <uJ**************@tk2msftngp13.phx.gbl>, John Cobb wrote:
I've removed the Microsoft.VisualBasic import from my VB.Net project and am
in the process of replacing the vb6 compatible calls with native .Net i.e.
system.datetime.now instead of Now, variable Is Nothing instead of
IsNothing(variable) etc. I cannot find a native .Net replacement for the
StrReverse function. Is anyone familiar with a quick fix?


How 'bout something like this :)

Private Function ReverseString(ByVal input As String) As String
If Not IsNothing(input) Then


LOL ;-)!

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #11
* Tom Shelton <to*@mtogden.com> scripsit:
If Not IsNothing(input) Then


Especialy that IsNothing(input) that is real the one.

:-))

Cor


Huh? I'm not following...


'IsNothing' is part of 'Microsoft.VisualBasic' and the OP doesn't want
to use this namespace ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #12
* "John Cobb" <jo*******@acxiom.com> scripsit:
Yes, that will work and I'll probably use something like that if there's not
a native .Net function already available. I was just curious if this
functionality was already part of the framework.


The Visual Basic .NET runtime actually /is/ part of the framework.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #13
Hi John,

Did you see OnError and Goto on the link I did send?

Are you sure it was not about the compatible namespace?

Cor


Nov 20 '05 #14
Dunno, I'll go back and check again. It's possible that I may be confusing
the two.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O0**************@tk2msftngp13.phx.gbl...
Hi John,

Did you see OnError and Goto on the link I did send?

Are you sure it was not about the compatible namespace?

Cor

Nov 20 '05 #15

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c6************@ID-208219.news.uni-berlin.de...
* "John Cobb" <jo*******@acxiom.com> scripsit:
I've removed the Microsoft.VisualBasic import from my VB.Net project and
am
Are you ill?

LOL. Not that I know of.
At the Develop Mentor Architect Training event hosted by Microsoft in
the Dallas office this week the instructor was showing how some functions
like
these are wrapped by .Net to allow backwards compatibility with vb6 and if
you use
ildasm to look at the intermediate language of your assembly you can see
where certain ones generate more IL than native .Net commands. It was
suggested there to remove the Microsoft.VisualBasic import and use true .Net
commands to generate leaner, tighter code. As a best practice, my team
leader has dictated we elminate the Microsoft.VisualBasic import from all of
our code.
Nov 20 '05 #16
In article <c6************@ID-208219.news.uni-berlin.de>, Herfried K. Wagner [MVP] wrote:
* Tom Shelton <to*@mtogden.com> scripsit:
If Not IsNothing(input) Then

Especialy that IsNothing(input) that is real the one.

:-))

Cor


Huh? I'm not following...


'IsNothing' is part of 'Microsoft.VisualBasic' and the OP doesn't want
to use this namespace ;-).


Oh, yeah! Ok, then change it to:

If Not input Is Nothing ....

Sorry.
--
Tom Shelton [MVP]
Nov 20 '05 #17
John,

* "John Cobb" <jo*******@acxiom.com> scripsit:
I've removed the Microsoft.VisualBasic import from my VB.Net project and am
Are you ill?


LOL. Not that I know of.


;-)
At the Develop Mentor Architect Training event hosted by Microsoft in
the Dallas office this week the instructor was showing how some functions
like
these are wrapped by .Net to allow backwards compatibility with vb6 and if
you use
Partly I agree. Some of the methods in the Visual Basic .NET Runtime
Library internally base on methods of the .NET Framework, but most of
them are more than a "wrapper". For example, 'IsNumeric' is performing
much more operations than you may expect it to do.
ildasm to look at the intermediate language of your assembly you can see
where certain ones generate more IL than native .Net commands. It was
suggested there to remove the Microsoft.VisualBasic import and use true .Net
I would not do that.
commands to generate leaner, tighter code.
Tell me, what's "cleaner" than 'Strings.StrReverse'? I don't see
anything dirty there.
As a best practice, my team
leader has dictated we elminate the Microsoft.VisualBasic import
from all of our code.


Tell him that this is nonsense ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #18
Hi,

There are lots of silly suggestions around. That sounds like one of them to
me. IMO, of course.

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
Nov 20 '05 #19
Hi Herfried,

As far as I know are the connection classes also a wrappers, I do not
believe that it is wise to delete those classes as well from the library

(That is in my opinion the main reason why there is always that discussion
about dispose with that one).

Just my thought,

Cor
Nov 20 '05 #20
* "Cor Ligthert" <no**********@planet.nl> scripsit:
As far as I know are the connection classes also a wrappers, I do not
believe that it is wise to delete those classes as well from the library


ACK. Wrapper <> bad.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #21
When it comes right down to it, some people have a phobia about the
name of that namespace (the "basic" part).

The solutions is simple - change the namespace name to
"System.CoolMiscellaneous", and everyone will be happy - hundreds of
very useful methods (that are currently being re-coded en masse by
programmers with far less experience than the the original coders of
these methods at Microsoft).

Or, be consistent in your phobia, and switch to C#.

Nov 20 '05 #22
When it comes right down to it, some people have a phobia about the
name of that namespace (the "basic" part).

The solutions is simple - change the namespace name to
"System.CoolMiscellaneous", and everyone will be happy - hundreds of
very useful methods (that are currently being re-coded en masse by
programmers with far less experience than the the original coders of
these methods at Microsoft).

Or, be consistent in your phobia, and switch to C#.

Nov 20 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Paul D. Boyle | last post: by
reply views Thread by Paul Hsieh | last post: by
9 posts views Thread by Freejack | last post: by
3 posts views Thread by Jeffrey D. Gordon | last post: by
32 posts views Thread by chris.fairles | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.