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

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

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

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
Overwrite character-VBForums
Results 1 to 9 of 9

Thread: Overwrite character

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    208

    Overwrite character

    Hi,
    Visual Basic
    I have a text box of 1 character . I have entered a character.
    Now I want to overwrite the charracter. How do I do it.

    I dont want to use backspace ..... delete the character and then
    agaian enter the character .

    I want to overwrite it. ......... Is it Possible

  2. #2
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,047
    If you mean manually then just highlight the letter to overwrite and type in the new letter.

    If you mean programtically then the following example replaces the 3rd letter of the text with "Z"

    VB Code:
    1. Text1.SelStart = 2
    2. Text1.SelLength = 1
    3. Text1.SelText = "Z"

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,425
    Don't forget to use SetFocus!

    Eg:
    VB Code:
    1. Private Sub Text1_Change()
    2.     Text1.SetFocus
    3.     Text1.SelStart = 0
    4.     Text1.SelLength = Len(Text1.Text)
    5. End Sub
    Last edited by Bruce Fox; Nov 24th, 2002 at 09:22 PM.
    Handy References:
    MSDN Library
    ADO Tutorial Excel Tutorial MZTools (VB6)

    • Please pull down the Thread Tools menu and click the 'Mark Thread Resolved' button, or alternately edit your original post and add "Resolved" or place a in the subject when your question(s) have been answered.
    • Please use code tags [highlight=vb] your code goes here between the tags [/highlight] when posting code.

  4. #4
    Addicted Member
    Join Date
    May 2001
    Posts
    237
    why not use Replace instead?

    if you want to replace the character "z" to "b" in a textbox:

    Text1.Text = Replace(Text1.Text, "z", "b")

  5. #5
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    Maybe i'm missing the point, but why not just
    VB Code:
    1. Text1.Text="b"
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  6. #6
    Addicted Member
    Join Date
    May 2001
    Posts
    237
    yes, if the text in the textbox is only 1 character...
    well.. that's what Micky asked in the first place

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    208
    Sirs,
    I have 4 text boxes each with One character input.

    I have entered the characters for the first 3 textboxes( through keyboard).

    Now my focus is on the fourth textbox.

    Now if I shift my focus to the 1st textbox and

    try to enter a character( from keyboard) it wont accept. What I

    have to do is first ERASE(backspace) the character

    and then enter another character.

    MY PROBLEM IS i DONT WANT TO USE BACKSPACE.

    i WANT TO OVERWRITE THE CHARACTER IN THE

    TEXT BOXES. Is it Possible................ Thnks ...........

  8. #8
    Addicted Member
    Join Date
    May 2001
    Posts
    237
    Code:
    Private Sub Text1_GotFocus()
        Text1.SelStart = 0
        Text1.SelLength = 1
    End Sub
    Now, each time text1 gotfocus, the whole text in the textbox is selected, so you don't have to use backspace or anything, just reaplace the text..

    does this solve your problem?

  9. #9
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    Try this. It deletes the text in the text box when it gains focus

    VB Code:
    1. Private Sub Text1_GotFocus()
    2.     Text1.Text = ""
    3. End Sub
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

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