Results 1 to 6 of 6

Thread: Reversing text in a text box????????

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 1999
    Location
    Leeds,Yorkshire,England
    Posts
    5

    Post

    Hi,

    I am writing a program so when you write text in a text box it displays the same text in a label but backwards eg.
    text box = Jason
    label = nosaJ
    Can someone please help me???
    Thanks in advance.

  2. #2
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314

    Post

    Thry this, it works..

    Word = Text1.Text
    L = Len(Word)
    Temp = String$(L, 32)

    For x = 1 To L
    a = Mid$(Word, x, 1)
    Mid$(Temp, (L - x) + 1, 1) = a
    Next x

    Label1.Caption = Temp

  3. #3
    Hyperactive Member
    Join Date
    Jul 1999
    Location
    NY, USA
    Posts
    270

    Post

    If you have VB6, then you can use the StrReverse function like this:

    Code:
    Private Sub Command1_Click()
         Text1.Text = StrReverse(Text1.Text)
    End Sub
    Remember, that only works with VB6.

    ------------------
    Tom Young, 14 Year Old
    [email protected]
    ICQ: 15743470 Add Me ICQ Me
    AIM: TomY10
    PERL, JavaScript and VB Programmer

  4. #4
    Hyperactive Member Steve Stunning's Avatar
    Join Date
    Jul 1999
    Location
    Fairfax, Virginia
    Posts
    314

    Post


    I did not know that... Learn somthing new here every day!!!

  5. #5
    Member
    Join Date
    Dec 1999
    Posts
    37

    Post

    If you don't have VB6, add two labels on your form

    Code:
    Private Sub Form_Load()
        Dim sstring As String
        Dim iposition As Integer
        
        Label1.Caption = "VB PROGRAMMER"
        
        sstring = Label1.Caption
        
        For iposition = Len(sstring) To 1 Step -1
            Label2.Caption = Label2.Caption & Mid$(sstring, iposition, 1)
        Next
    End Sub
    Hope this works for you

    Ruchi

  6. #6
    Addicted Member
    Join Date
    Jan 1999
    Location
    Sydney,NSW,Australia
    Posts
    178

    Post

    Just try formatting your string on the text click event, (in vb5) automatically reverses it.

    txtEntry.Click()
    txtEntry = UCASE(txtEntry)

    Just add whatever code you want to use for this weird happening, e.g label = UCASE(txtEntry)

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