Excel User Form using VBA

sachinns

Board Regular
Joined
Jun 21, 2019
Messages
52
Hi Folks,

I am very new to VBA as well as this forums . So i need your support.

1. Need code for deleting the values in the textbox using keyboard (like using delete/backspace on the keyboard)
- Deleting values like last words , not by single single alphabets. Eg : if the textbox contains ( Number of poles ) , when i press backspace 'poles' should be removed not the 's' )
2. I want to add values of a button to a textbox where ever the cursor is there , In my code the values will be added to the last of the textbox always.

CODE:

Private Sub Addition_Click()
If TextBox2.Text = "" Then
TextBox2.Text = " + "
Else
TextBox2.Text = TextBox2.Text + " + "
End If
End Sub



Please help me guys.
Thanks in advance.
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,743
Office Version
2013
Platform
Windows
Re: Excel User Form using VBA : Help Needed

I know of no script which will run when you hit backspace Key.
You said:
Need code for deleting the values in the textbox using keyboard (like using delete/backspace on the keyboard)

Please explain more about your ultimate Goal and not how to do it.

You also said:
I want to add values of a button to a textbox

So are you saying your button caption is a number like 12

 

sachinns

Board Regular
Joined
Jun 21, 2019
Messages
52
Re: Excel User Form using VBA : Help Needed

Hi,



This is user form look like. When i press the buttons like +,-,* . It will come to formula Description. So if User enters wrong data they want to remove it using backspace or delete button in keyboard.

Also, if user keep the cursor anywhere in the Formula Description and then press the buttons like +,-,/ . Value should come in that cursor position not the last of that textbox.

I hope now it is clear for you.

Thanks
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,743
Office Version
2013
Platform
Windows
Re: Excel User Form using VBA : Help Needed

Yes I understand more now.
I know of no way to enter value where cursor is positioned.

I believe your saying if Description Says:

Peter is my friend.

You want to position cursor after my and then when you click on a button you want to enter Good just after My

This is beyond my knowledgebase.
I will continue to monitor this thread to see what I can learn.
 
Last edited:

sachinns

Board Regular
Joined
Jun 21, 2019
Messages
52
Re: Excel User Form using VBA : Help Needed

Yeah Exactly.

I need 2 help. One is this which you told and another one is that , Taking your example.

If the Description says "Peter is my friend" . If i press the backspace key or Delete button in my keyboard , it should delete friend from the description and if i press again the space should deleted and if i press again it should delete my and so on.
Do you how to do this one.

Thank you
 

Watch MrExcel Video

Forum statistics

Threads
1,095,479
Messages
5,444,728
Members
405,298
Latest member
fxtrtr17

This Week's Hot Topics

Top