Solved

Erase the text

Posted on 2009-04-02
5
124 Views
Last Modified: 2012-05-06
How to erase the text as shown example below?
Private Sub Command1_Click()
Text1.Text = Left(Text1, Len(Text1) - 1)
End Sub

now in text1.text has number of  "12345"
Can i erase the 4 or any of them using commandButton by pointing the cursor after the number i wanted to erase?

Thanks a lot!
0
Comment
Question by:Whing Dela Cruz
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:cmrobertson
Comment Utility
text.seltext in the textbox will give you the position in the textbox that is currently selected you can then create a string pulling that one out if you need details to accomplish let me know, sorry i was going to put in last q but it was closed
0
 

Author Comment

by:Whing Dela Cruz
Comment Utility
Can you give me example?
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 300 total points
Comment Utility
Give the TextBox Focus and then send a BackSpace.  Whatever was before the cursor will be erased...
Private Sub Command1_Click()

    Text1.SetFocus

    SendKeys "{BACKSPACE}"

End Sub

Open in new window

0
 
LVL 7

Assisted Solution

by:cmrobertson
cmrobertson earned 200 total points
Comment Utility
a = Me.Text
b = Mid(Me.Text.Text, 1, Me.Text.SelStart) & Mid(Me.Text.Text, Me.Text.SelStart + 2)
this assumes cursor in front of letter to eliminate
0
 

Author Closing Comment

by:Whing Dela Cruz
Comment Utility
Thanks Both of you,
The code is working...
Thanks a lot! More Power!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now