Results 1 to 3 of 3

Thread: String Reversal

  1. #1

    Thread Starter
    Addicted Member Cbomb's Avatar
    Join Date
    Jul 1999
    Posts
    153

    Post

    I've see code posted before that reverses either a string or a file. Does anyone have this code on hand? Thanks in advance.
    Cbomb
    Techie

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Post Try this...

    The easiest way to reverse a string that I know of...

    Create a project and place a command button and a text box on the form.

    Paste the following code into the form's code window, run the project, type some text into the text box, and then click the command button.

    Code:
    Option Explicit
    
    Private Function ReverseString(sStringIn As String) As String
        Dim nCounter As Integer
        
        For nCounter = 1 To Len(sStringIn)
            ReverseString = Mid$(sStringIn, nCounter, 1) & ReverseString
        Next nCounter
    End Function
    
    
    Private Sub Command1_Click()
        Text1 = ReverseString(Text1)
    End Sub
    Unless you are using VB6.0, of course, which has a string reverse function built in, called StrReverse. This is implemented in the same manner:
    Code:
        Text1 = StrReverse(Text1)
    Edited by seaweed on 03-12-2000 at 08:40 PM
    ~seaweed

  3. #3
    Guest

    Post

    Of interest if you are using vb5, but the following code into a Textbox change event.

    Private Text.Change()

    Text = ucase(Text)

    Reverses the text string, strange but true.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width