Results 1 to 8 of 8

Thread: String functions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Colorado
    Posts
    23
    Can anyone hlp me with the coding for the two events below? Thanks.

    Reverse Text
    · Write code to reverse the text a user enters in "txtEntry1" when the user clicks the button "cmdReverseText". Display the result in the label "lblResult". For example, an entry of :

    "Hello World!"

    would cause the following text to appear in the label "lblResult" when the user presses the button "cmdReverseText".

    "!dlroW olleH"



    · Clear the result display.

    · Remove leading and trailing spaces from the text before reversing it.

    · Check that the user has entered at least one character.

    · Save the project.

    · Run several tests.



    Count Occurrences
    · Write code to count the occurrences of "txtEntry2" in "txtEntry1" when the user clicks the button "cmdCount". Display the result in the label "lblResult". For example, entries of

    "This is some text this is" and "is"

    would cause the following text to appear in the label "lblResult" when the user presses the button "cmdCount".

    "Occurrences Found : 4"

    · Clear the result display.

    · The count should NOT be case-sensitive.

    · Remove leading spaces from the text before reversing it.

    · Check that the user has entered at least one character in both text boxes.

    · Save the project.

    · Run several tests.

    Hints:
    use Mid and Instr functions among others

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    To reverse the text use
    Code:
    lblResult.caption = StrReverse(txtEntry1.text)


    [Edited by Vlatko on 11-05-2000 at 01:40 PM]
    I am become death, the destroyer of worlds.
    mail:vlatkovr@hotmail.com

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    ' Clear the result display.
    Mylbl.Caption = "" '?
    
    ' Remove leading and trailing spaces from the text before reversing it. 
    Text1.Text = Trim(Text1.Text) 
    
    · Check that the user has entered at least one character. 
    If Len(Text1.Text) > 0 Then 'user entered at least one char. 
    
    · Save the project. 
    You can't save a project at runtime?! 
    
    · Run several tests. 
    What kinda tests you wanna run?


    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Who are you refering too?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    Jop how did u format the text in the form of vb?

  7. #7
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    use [code] and [/code]
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  8. #8

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