Results 1 to 5 of 5

Thread: string manipulation

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    4

    string manipulation

    i have a general question about string manipulation:

    let's say for example that i have an input box. in this input box a user can type in any random string of characters (e.g. ALWOGHKEIRT). How would I code a button so that each time it is clicked a space is inserted between "W"'s and "O"'s for example? so, "ALWOGHKEIRT" becomes
    "ALW OGHKEIRT" (or "DPLIJWOLMNSGWOP" becomes "DPLIJW OLMNSGW OP" or any other random string)

    thanks

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: string manipulation

    Quote Originally Posted by superTA
    i have a general question about string manipulation:

    let's say for example that i have an input box. in this input box a user can type in any random string of characters (e.g. ALWOGHKEIRT). How would I code a button so that each time it is clicked a space is inserted between "W"'s and "O"'s for example? so, "ALWOGHKEIRT" becomes
    "ALW OGHKEIRT" (or "DPLIJWOLMNSGWOP" becomes "DPLIJW OLMNSGW OP" or any other random string)

    thanks

    Dim a As String = "DPLIJWOLMNSGWOP"
    a = a.Replace("WO", "W O")

    rate my post
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    4

    Re: string manipulation

    mr. polite

    thanks for the response. only thing: i need that concept to work for any string that the user types into the input box.

    so, for any string typed into the input box would i write:
    Dim a As String = inputbox.text
    a = a.Replace("WO", "W O")

    or something like

    Dim errString As String = InputBox.Text
    Dim correctString As String = errString.Replace("WO", "W O").

    as i can tell, your method applies specifically, to the "DPLIJWOLMNSGWOP" in my example. but, it should apply for any string typed into the input box

    your input is appreciated

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: string manipulation

    Either of your two examples would work, but the second one will require a different variable, which is slightly less efficient than the first example.

    Personlaly, I prefer to define the variable:

    Dim str as string

    Then assign to it:

    str=InputBox.text


    But that is just my preference. I feel it is more readable, but it should make no difference in performance.
    My usual boring signature: Nothing

  5. #5
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Re: string manipulation

    doesnt matter how you do it. It just depends to your preferences as shaggy hiker said. If you dont need the original inputted string then you dont really need a separate variable for that. You can keep it as short as this:

    Dim strInput As String = InputBox.Text.Replace("WO", "W O")
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

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