I know this may seem pretty simple to most but I need to reverse a string. So like if the user types "WX YZ" I want the output to be "ZY XW" Is there a way to do that using a loop?
Thanks in advance.
Printable View
I know this may seem pretty simple to most but I need to reverse a string. So like if the user types "WX YZ" I want the output to be "ZY XW" Is there a way to do that using a loop?
Thanks in advance.
that should do it, although there may be a better way using the .Reverse property of arraysVB Code:
Dim s As String = "This is the string" Dim ReverseString As String = "" For i As Integer = s.Length - 1 To 0 Step -1 ReverseString &= s.Substring(i, 1) Next
kevin
If you want to do it without a loop...
VB Code:
Dim h As String = "Hello" Dim chars As Char() = h.ToCharArray Array.Reverse(chars) h = New String(chars)
i though you could do it w/o a loop, i just didn't know how to get from the char array back to a string. cool :cool: :thumb:
Hi,
Wont something like the following do it:
Label1.Text = StrReverse(TextBox1.Text)
HTH
Alan
That shoud be deprecated these days.
just curious, but why?Quote:
Originally Posted by DNA7433
Because its an old vb6 function you should always use .net .Quote:
Originally Posted by kebo
is it not managed by the CRL?Quote:
Originally Posted by Asgorath
Is there a guide for these old functions somewhere that points to the appropriate .NET version? For example, I'm being taught in class to use the IsNumeric() function to do some basic validation. Is this a VB6 hold-over? If so, what's the .NET equivalent? I'd love to find a link or document somewhere so that I can lookup whether or not a function/method is a VB6 holdover and find the replacment .NET function/method. I don't really have a frame of reference since I'v done virtually no VB6 programming and what little bit I HAVE done was over 6 years ago.
Thanks,
Steve
no it is.. but its basically included in the framework for backwards compatibility to help VB6 programmers upgrade apps easier... to make the VB6 to VB.NET upgrade wizard produce less errors you have to fix.. etc...Quote:
Originally Posted by kebo
generally the .net ways you can accomplish the same task tend to be better on performance than the VB6 compatibilty functions (even though I will admin some will show little to no difference over all, possibly in some massive loops or complex coding)
but like I said before, its better just from a .net programmer standpoint if you need to work on C# or something, it will be much easier if you stick to the core of the .net framework
this is probably true but with out taking performance into account,Quote:
Originally Posted by kleinma
is easier to read and code thanVB Code:
Label1.Text = StrReverse(TextBox1.Text)
Having said that though, I would still prefer to do it the .net way.VB Code:
Dim chars As Char() = TextBox1.Text Array.Reverse(chars) Label1.Text = New String(chars)
kevin