Reversing characters in a string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kellysgirl
    New Member
    • Mar 2007
    • 9

    Reversing characters in a string

    Private Sub displayButton_C lick(ByVal sender As Object, ByVal e As System.EventArg s) Handles displayButton.C lick
    ' creates and displays a new password

    Dim origPassword As String
    Dim newPassword As String = String.Empty
    Dim indexNum As Integer

    ' assign input to a variable (the origPasswordTex tBox's CharacterCasing
    ' property is set to Upper)
    origPassword = origPasswordTex tBox.Text

    ' verify that the password contains 5, 6, or 7 characters
    If origPassword.Le ngth >= 5 AndAlso origPassword.Le ngth <= 7 Then
    ' replace all vowels (A, E, I, O, and U) with an X
    origPassword = origPassword.Re place("A", "X")
    origPassword = origPassword.Re place("E", "X")
    origPassword = origPassword.Re place("I", "X")
    origPassword = origPassword.Re place("O", "X")
    origPassword = origPassword.Re place("U", "X")

    ' replace all numbers with a Z
    origPassword = origPassword.Re place("0", "Z")
    origPassword = origPassword.Re place("1", "Z")
    origPassword = origPassword.Re place("2", "Z")
    origPassword = origPassword.Re place("3", "Z")
    origPassword = origPassword.Re place("4", "Z")
    origPassword = origPassword.Re place("5", "Z")
    origPassword = origPassword.Re place("6", "Z")
    origPassword = origPassword.Re place("7", "Z")
    origPassword = origPassword.Re place("8", "Z")
    origPassword = origPassword.Re place("9", "Z")

    ' reverse the characters in the password



    ' display the new password
    newPasswordLabe l.Text = newPassword

    Else ' processed when the password is not the correct length
    newPasswordLabe l.Text = ""
    MessageBox.Show ("Please enter 5, 6, or 7 characters.", "Password", _
    MessageBoxButto ns.OK, MessageBoxIcon. Information)
    End If

    origPasswordTex tBox.Focus()

    Hey is there a function that allows you to reverse characters if so what is it
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    [PHP]StrReverse("yor string here")[/PHP]

    Comment

    • kellysgirl
      New Member
      • Mar 2007
      • 9

      #3
      Originally posted by iburyak
      [PHP]StrReverse("yor string here")[/PHP]


      Thank you so much. I really appreciate it

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Simply try String.Reverse it will work

        Comment

        Working...