How about this?
'-----------------------------------------------------------------------
Option Strict
Imports System
public Class [class]
Public Shared Sub Main
Dim s As String = "Some randomly selected string to reverse"
Console.WriteLine(s)
Console.WriteLine(Reverse(s))
End SUb
Public Shared Function Reverse(s As String) As String
Dim c1() As Char = s.toCharArray
Dim offset As Integer = c1.length - 1
Dim c2(offset) As Char
For ndx As Integer = 0 To offset
c2(offset - ndx) = c1(ndx)
Next
Return New String(c2)
End Function
End Class
'-----------------------------------------------------------------------
: Thanks for the reply. I know about that and yes it does work. I just
heard
: there was a way to do it using a loop and I am having trouble getting
it to
: work.
:
: Regards,
:
: minguskhan
:
: "Peter Proost" wrote:
:
: > Hi,
: >
: > first why doesn't
: >
: > StrReverse( ) work for you?
: >
: > for example:
: > TextBox1.Text = StrReverse(TextBox1.Text)
: >
: > This is a loop that does the same as StrReverse
: >
: > Dim strToReverse As String
: > strToReverse = TextBox1.Text
: > TextBox1.Text = ""
: > For i As Integer = strToReverse.Length To 1 Step -1
: > TextBox1.Text &= Mid(strToReverse, i, 1)
: > Next
: >
: >
: > hth Greetz Peter
: >
: > --
: > Programming today is a race between software engineers striving to
build
: > bigger and better idiot-proof programs, and the Universe trying to
produce
: > bigger and better idiots. So far, the Universe is winning.
: >
: >
: > "minguskhan" <
[email protected]> schreef in
bericht
: > : > > Does anyone know how to reverse a string using a loop?
: >
: >
: >