Solved

Erase the text

Posted on 2009-04-02
5
125 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
ID: 24051057
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
ID: 24051102
Can you give me example?
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 300 total points
ID: 24051108
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
ID: 24051135
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
ID: 31565841
Thanks Both of you,
The code is working...
Thanks a lot! More Power!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

912 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

20 Experts available now in Live!

Get 1:1 Help Now