I've see code posted before that reverses either a string or a file. Does anyone have this code on hand? Thanks in advance.
Printable View
I've see code posted before that reverses either a string or a file. Does anyone have this code on hand? Thanks in advance.
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.
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: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
Edited by seaweed on 03-12-2000 at 08:40 PMCode:Text1 = StrReverse(Text1)
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. :)