?
Solved

Reversing the text

Posted on 2003-03-07
13
Medium Priority
?
197 Views
Last Modified: 2010-05-01
i have got a multilinetext. i would like to reverse the text i.e mirror image of the text is to be obtained.
for example if i have

this
an
expert

in 3 seperate lines then i should get the result as

siht
na
trepxe

in 3 seperate lines into another textbox. please help me out.i want the coding in Visual basic. I require it urgently.
0
Comment
Question by:ayesha16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +7
13 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8087296
First, try use the Split function to split the text, then use the StrReverse function to reverse the text..
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 8087310
Hi ayesha16,

    Dim aryLines() As String
    aryLines = Split(Text1.Text, vbNewLine)
    For i = LBound(aryLines) To UBound(aryLines)
        strText = ""
        For c = 1 To Len(aryLines(i))
            strText = Mid(aryLines(i), c, 1) & strText
        Next
        Text2.Text = Text2.Text & strText & vbNewLine
    Next

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8087323
Here is an example:

Private Sub Command1_Click()
    Dim tmp As String, filePath As String
    Dim tmpArr() As String
    Dim newContent As String
    filePath = OpenDialog(Me)
    If filePath <> "" Then
       
        tmp = ReadFileText(filePath)
       
        tmpArr = Split(tmp, vbCrLf, , vbTextCompare)
       
        For i = 0 To UBound(tmpArr)
            If i <> 0 Then
                newContent = newContent & vbCrLf & StrReverse(tmpArr(i))
            Else
                newContent = StrReverse(tmpArr(i))
            End If
        Next i
       
        WriteFileText "C:\abc.txt", newContent
        MsgBox "Done!"
       
    End If
   
End Sub

Private Function ReadFileText(ByVal FileName As String) As String
    On Error GoTo EHandler
    Dim Handle As Integer
    Handle = FreeFile
    Open FileName For Input As #Handle
        ReadFileText = Input$(LOF(Handle), Handle)
        On Error Resume Next
    Close #Handle
    Exit Function
EHandler:
    ShowErrMsg
    On Error Resume Next
    Close #Handle
End Function

Public Function WriteFileText(ByVal FileName As String, ByVal Source As String) As String
    On Error GoTo EHandler
    Dim Handle As Integer
    Handle = FreeFile
    Open FileName For Output As #Handle
        Print #Handle, Source
        On Error Resume Next
    Close #Handle
    Exit Function
EHandler:
    ShowErrMsg
    On Error Resume Next
    Close #Handle
End Function

cheers
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 26

Expert Comment

by:EDDYKT
ID: 8088021
Does it sound like homework?

How come sometime we provide the solution and sometime we ask the code and then provide the fix?

0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 8088033
I buy  ryancys's first idea only provide some guideline and let them figure out the problem. However,  ryancys provide solution later?
0
 

Expert Comment

by:cocomobasic
ID: 8089653
Private Sub Command1_Click()
Dim str As String
Dim i As Integer
Dim char As String

    str = StrReverse(Text1.Text)

    For i = 1 To Len(str)
   
        char = Mid$(str, i, 1)
        If char = vbLf Then
       
            Text2.Text = Text2.Text & vbCrLf
           
        ElseIf char = vbCr Then
        Else
       
            Text2.Text = Text2.Text & char
       
        End If
   
    Next

End Sub

this is assuming you have both textbox the same length
0
 

Author Comment

by:ayesha16
ID: 8097241
thank u very musch for the answer provided. mmmmmy problem has been solved.
0
 

Author Comment

by:ayesha16
ID: 8097300
i have got a multilinetext. i would like to reverse the text i.e mirror image of the text is to be obtained.
for example if i have

this
an
expert

in 3 seperate lines then i should get the result as

siht
na
trepxe

in 3 seperate lines into the same textbox.I want the coding in Visual basic. I require it urgently.
0
 

Expert Comment

by:vikram_c90
ID: 8097505
Ayesha, I think u must accept an answer whihc helped to solve your problem, so that that person can get the points for it.
0
 

Expert Comment

by:Rogue_VB
ID: 8646730
any expert who thinks he is going to get any points here, think again!!!!

refer to this link for details:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/viewMember.jsp?mid=1003046

note all the open questions..
0
 

Expert Comment

by:CleanupPing
ID: 8900526
ayesha16:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9074318
Moderator, my recommended disposition is:

    Save as PAQ -- No Refund.

DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9165928
Question is PAQ'd and no points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question