PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 Please help easy problem i think :(-VBForums
Results 1 to 3 of 3

Thread: Please help easy problem i think :(

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Location
    israel
    Posts
    1

    Please help easy problem i think :(

    Hi, i'm kinda new to vb and i need to develope a part of a project and i'm stuck.

    I have a textbox and i want to replace the third letter of the word to "X" that will be written in the textbox for example:

    "working all day"
    "woXing all day" i changed the letter r to X

    How can i specify the position of the letter in the texbox.

    PLease help
    Thank you.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,597

    Re: Please help easy problem i think :(

    vb Code:
    1. dim str as string = textbox1.text
    2. dim charPosition as integer = 3
    3. dim newChar as string = "X"
    4. str = str.substring(0, charPosition -1) & newChar & str.substring(charPosition)
    5. msgbox(str)

  3. #3
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Please help easy problem i think :(

    You can also do it with remove and insert.

    Code:
            Dim myString As String = "working all day"
            myString = myString.Remove(2, 1).Insert(2, "X")
            MessageBox.Show(myString)
    Note that 2 is the index, since the first character in the string is at position 0. That makes the 3rd character in the string position 2.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width