String reversal

Code:
backstring.Replace(" ","")
would remove the spaces, however heres a quicker way....
Code:
Dim backstring As String
		
		TextBox1.Text = TextBox1.Text.ToUpper.Replace(" ", "")

		Dim chars() As Char = TextBox1.Text
		Array.Reverse(chars)

		backstring = New String(chars)

		If backstring = TextBox1.Text Then
			MsgBox("YaHooo")
		Else
			MsgBox("BooHooo")
		End If
 
Last edited by a moderator:
This is what I ended up with what do you think

This is what I ended up with what do you think??
It works fine.

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim newstring As String
        Dim backstring As String
        Dim temp As String
        Dim mystringlenght As Integer
        Dim x As Integer
        

        temp = TextBox1.Text.ToUpper.Replace(" ", "")
        mystringlenght = TextBox1.TextLength

        
        For x = mystringlenght To 1 Step -1
            backstring = Mid(temp, x, 1)
            newstring = newstring & backstring

        Next

        If newstring = temp Then
            MsgBox("YaHooo")
        Else
            MsgBox("BooHooo")
        End If




    End Sub
End Class
 
Back
Top