Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




BackSpace Key


Hi Gurus



Thanks to BIG JABBA for my previous query 'RE: Txt_LostFocus and Exit Buton
. It is working but with some modification. My next query is:



Generally the BACKSPACE key is inactive in a TEXT BOX where only digits re
required and the code is put in keypress event to ensure that only digits
can be keyed in .



What is the code to put in keypress event of TEXT BOX so that it does its
function. Waiting for your reply.



Rajiv




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Backspace
Hey, need a little help.

Please could someone tell me how to make a backspace button for a textbox.
(meaning a button, which when pressed, will delete the last character in a text box)

Thanks.

Need Backspace
in my Textbox I need that you only can input letters. That had I but I need too that you can use the backspace, that's it only clear one letter. I had tried it but it doesn't goes. here is the Code I had already:


Code:
Private Sub cboArtikel_KeyPress(KeyAscii As Integer)
If KeyAscii < 65 Or KeyAscii > 90 Then
If KeyAscii < 97 Or KeyAscii > 122 Then
KeyAscii = 0
End If
End If
End Sub

Backspace
Hey

Im doing a quick application as a calculator, and want a back button so it deletes the last character the user typed.

Would I use the len?

I tried Len(lblCalc.Caption) - 1

This was arough guess, but I dont know exactly how to do it. Any pointers in the right direction?

Allow Backspace
How can i allow my custom textbox to accept Backspace?
I only want to let it accept numbers, but now backspace doesn't work anymore


VB Code:
Case Numbers If IsNumeric(Chr(KeyAscii)) = False Then KeyAscii = 0BeepExit SubEnd If

RTB And Backspace
I need help... Everytime i press backspce too edit some text in my RTB it scrolls too the top ! This is pretty annoying if you get my point

BackSpace
Hi,
I want to use a backspace character such as /b in C. My code and output are as shown below...

VB Code :-
----------
dim str as string
str = "Hellw" & vbKeyBack & "o"

msgbox str

output :-
--------
Hellw8o

But i want it to be "Hello" . Can any one tell how i can solve this problem.......

Backspace In RTF?
I would like to know how to perform a backspace in my program using visual basic 6. For example, if the user keyed in a "~", I would perform a backspace to remove this particular character.

Please note that I had try to use LEFT, MID and some other function that can achieve this taskl, but however, previous characters will all change to only one colour.

Sincerely asking for help

Thank you.

Backspace In RTF?
I would like to know how to perform a backspace in my program using visual basic 6. For example, if the user keyed in a "~", I would perform a backspace to remove this particular character.

Please note that I had try to use LEFT, MID and some other function that can achieve this taskl, but however, previous characters will all change to only one colour.

Sincerely asking for help

Thank you.

Backspace
Is there an ascii char for performing a backspace?

TIA,
Linda

Backspace
hello to all

my next problem i have encountered (i encounter so many problems) is the backspace.
i have two text boxes, the user enters text into 1 and it shows in both text boxes.
ive used ascii key press to do this so far. but i need the backspace aswell, and i cant find
the ascii for the backspace.

so can anybody tell me the ascii for the backspace if it exists, or help me with another way
to do it.

thanks.



Edited by - Primary_Slave on 7/11/2004 1:07:47 PM

Vb BackSpace
The following code works fine to recover an appended file but because of the( VbcrLf) it
winds up with a carriage return. If one then appends the file again and recovers it a
blank line is left because of the carriage return on the end. A Vb backspace would
correct this but I find no such listing. What is the solution?

Private Sub RecallList()
Text9.Text = "": Dim T
Text9.Visible = True
Close #1
Open "c:WindowsAllRecords.txt" For Input As #1
Do Until EOF(1)
Input #1, NewLine
Text9.Text = Text9.Text + NewLine & vbCrLf
Loop
Close #1
End Sub

Backspace Key
what is the ascii code of the backspace key
and how i write it in command
like
ENTER: "hi + chr$(13) + chr$(10)"

BackSpace
I am writing a calculator for school. Everything works fine except for the BackSpace button. I want to delete the last digit entered, but instead of deletaing it I am subtracting one from it. If I enter 10 and hit BackSpace I get 9 instead of 1. Can anyone help me out here?

Thanks,

Chris

Automated Backspace
I'm creating a Word document from VB6. I have a word instance open and the document is coming out fine, but I'm using INCLUDETEXT to insert a template into a template multiple times.

The problem is that between the two inserted templates there are two enters and I only want one. Now I was trying to let the VB code use a backspace after every insert, but I can't figure out the syntax. I'm using this:


Code:
objDoc.ActiveWindow.Selection.TypeBackspace
But in that case my program returns:
"5941: The requested member of the collection does not exist" < It's translated from dutch so might be differtent in English
Leaving away the "ActiveWindow" part results in:
"Object doesn't support this property or method"

I'm using Word 2000 by the way.
I hope someone can give me a quick answer on this.

Regards,
Maurits

Backspace Keypress
hey guys!

i was jkust wondering with visual studio, how i would set a keypress to being backspace for it t change. The cpde below is for a keypress of enter, and i was wondering what i need to replace to make it a backspace key instead. thanks!

If e.KeyChar = vbCr And txtName8.Visible = False And txtName6.Text = "" = False Then 'Enter pressed
btnPlay.Focus()
End If

Backspace Button
could anyone tell me how to make a backspace button for a textbox? i only want to delete the last character entered, not all of the text in the text box.

thanks.

Delete (BackSpace)
ok, ive managed to make my program open a web browser, click at a point where a form is, now how to i make it do like backspace and delete the last charactor?

Detecting Backspace????
I noticed that, in order to delete a character in a textbox, I need to use the "Delete" key. Is there a way to activate the "Backspace" key, or do I have to do that programmatically? For example (if I have to do it programmatically), how would I do this...

before: ABCDE
after: ABDE

Thanks all!

Backspace Char
Hello,
I just wanted to see if anyone could help me figure out what to use to tell when the backspace key is hit. Sort of like a vbenter but for backspce.
thanks

Numbers And Backspace Only
I have written a math program for which I would like the user to only use the numbers 0 to 9 and the backspace key and the return key. I have searched this forum and found some clues as how this should be done, but somehow I cant get it to work in my code. Here is the code.

Private Sub Text1_Keypress(KeyAscii As Integer)

If KeyAscii = 13 Then

If Val(Text1.Text) = Val(Lbl1 * Lbl2) Then
KeyAscii = 0
Score = Score + 1
Total = Score + WrgAns
lblScore.Caption = ("You have " & Score & " out of " & Total & " correct")
Picture1.Picture = LoadPicture(App.Path & "Tick.jpg")
Text1.Text = ""
Else
KeyAscii = 0
WrgAns = WrgAns + 1
Total = Score + WrgAns
lblScore.Caption = ("You have " & Score & " out of " & Total & " correct")
Picture1.Picture = LoadPicture(App.Path & "Cross.jpg")
Text1.Text = ""
End If

If Option1.Value = True Then
Call Option1_Click
ElseIf Option2.Value = True Then
Call Option2_Click
Else
Call Option3_Click
End If
End If
End Sub

Perhaps something like this would work:

If not KeyAscii=8 then
If KeyAscii < 48 or KeyAscii > 57 then
KeyAscii=0
End if
end if

But where would I put it?


Any ideas on how I could do it would be appreciated. Sorry the code is not formatted like I have seen it on this forum. Perhaps someone could tell me how to do that as well. Is it a case of copy and pasting?

Thanks

Backspace Button
Im looking for some help on a button named cmdBackspace, Its going to be part of a calculator.
I havent a clue how to code a button that will act like the backspace key on the keyboard.

Cheers
Steve

Lil Backspace Problem
because i put my text disabled so i ve made a keycode thin on my backspace button and i got a problem when hittin backspace when my text is empty. Run-time error '5':
Invalid procedure call or argument

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 8 Then
txt = Left(txt, Len(txt) - 1)
End If

Using BackSpace In Text Box
In programs I'm writing in VB5, I would like to give the User the option to remove the last character in a text box using the backspace key.

I use this code in a _keypress event procedure :
If ........... then
................
elseif ................. then
................
elseif ................. then
.................
elseif keyascii = 8 then
txtABC.text = Left$(txtABC.text, len(txtABC.text) - 1)
else
..................
end if

This does the job allright, BUT when the shortened text string is displayed in the text box, the cursor is placed at the start of the line of text, whereas I
would prefer it was placed at the end of the string where it should be.

Is there any code I can add to force the cursor to the end of string.

Warren Sugden

Keycode For Backspace?
What is the keycode for Backspace?

And how do i know the keycodes for all keys? is there a piece of code for it?

Allowing Backspace?
Limiting input to textbox...
Only allow 0 to 9, but allow backspace?
This code doesn't work...

VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)'---Only allow "0 to 9", but allow "6/Backspace"    If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 6 Then        KeyAscii = 0    End IfEnd Sub

Know a solution?

Calc Backspace - Need Help
I am trying to write a basic calculator program. I need to know on command.click what to use for a backspace in a display instead of clearing the whole thing.

Backspace A Textbox
if you have a textbox and a command button, called cmdBackspace, what would be the code so when they click cmdbackspace, it deletes the last character out of the textbox?

Telnet Backspace
Perhaps this is a hard question.

I'm making my own telnet server.

I have to print everything the user types for example:

User is typing: Help

Then my VB app has to print Help back to make it show up in the telnet-client.

But the problem occurs when users are trying to use their backspace.

I get this result:



Is there I way I could send backspace and actually make the typed text dissapear?

Ascii For Backspace Key
Hello there,
Does anyone out there know the ASCII code for the backspace key. I've looked through the MSDN library and I can't find it.

Tesita

Backspace Function (again)
Me again with new old question...

last time I wanted the code for a backspace function.

I got this one:
-----------------------------------------
thetext=left(thetext,len(thetext)-1)
-----------------------------------------

It worked perfecty on a textbox, but not on a "as double" number
(with an "as double" number I mean that you've typed:
dim thenumber as double)

This time I need one that does.

Ex.: If the number = "238" the backspace function should make it "23"

Thnx,
-Tonnic-

Backspace Function
hi, here's another question

to understand the question you might just want to open your windows calculator (if u have 1 )

i'm looking for the code to make an 'Backspace' button. I want It to function just like the 1 on your keyboard... (if you press it, last charactar disappears..)

sooo... what the code ?

BACKSPACE Pressed
Hi everybody!! I am wondering whether there's a way to "capture" the backspace key. For example, is there any way to detect when the Backspace key is pressed without any textbox_Keypress event. I just don't want to be setting the focus (with a timer) to one Textbox to capture the key events... Does anybody has any solution?

BackSpace Problem
Hi there.

I have a problem, here is my code:


Code:
Private Sub Grid1_KeyPress(KeyAscii As Integer)
Grid1.Text = Grid1.Text & Chr(KeyAscii)
End Sub


every time i press the backspace button "chr(8)" it ads an vertical bar insted of erasing the last charecter, can someone help me out?

numibesi

Decimal And Backspace
If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 13

I am using the above and need to add backspace and decimal to the allowed characters. I'm at work and don'thave msdn to look it up...

Help please...code...chr(ascii) what?

Backspace In Calculator
I'm having problems with implementing backspace in my calculator.Can someone please explain the code or the logic for it.I tried one logic but with that i'm able to delete only one digit that was previously entered.please help.

Backspace Key Code
ITtoolbox Portal for Visual Basic - http://visualbasic.ittoolbox.com/

Hi all,
Can any one help me in writing the code for backspace
key

Thanks,
Nidhi

--- "John J. Scott" < email@removed wrote:
> ITtoolbox Portal for Visual Basic -
> http://visualbasic.ittoolbox.com/
>
> For Action Of
>

Activation Of The Backspace Key
hi,

I am testing a string a usertypes in a combobox textarea but i see the backspace key is not activated.
I have seen the right to left property of the form = false ,but i did't succeed to change it to true.

Do you think it is the reason why the key backspace is not activated.

thanks a lot for you help.

Regards.

Nathalie

Backspace Button
how can i use a cmdbutton to erase the most recently entered number in a label? And only one character at a time

Need Help With How To Detect Backspace
i'm doin a net chat program, the letter that i type will intantly send to the other computer, but when i hit the backspace, i have to send a msg to let the other computer delete the last letter that i typed..
first .. how do i detect if i hit backspace...
second.. wat do i send to let the other computer to delete the last character

Backspace Button
hi guys,

I have a textbox and a button in my form that i want to act as a Backspace button. How can i do this?

thanks

Backspace Or Going Back
HI
i would like to know if there an easy way to move backwords with textboxes. When i press enter on a text box the focus move to the next one with the number higher than the previous one.
How do u go backwords?

Thank's a lot for your help!
Frank

Vbterm Sample App And Backspace Key
How come when I hit the backspace key, it adds the funky characters instead of deleting the charater to the left like it is supposed to do in the vbterm example included with VB6?

' Filter/handle BACKSPACE characters.
Do
i = InStr(Data, Chr$(8))
If i Then
If i = 1 Then
Term.SelStart = TermSize - 1
Term.SelLength = 1
Data = Mid$(Data, i + 1)
Else
Data = Left$(Data, i - 2) & Mid$(Data, i + 1)
End If
End If
Loop While i

Disable Backspace On Userform
Hello,

I can't seem to figure out how to disable (keyboard) backspace usage in a textbox on a userform. I use Office XP Excel VBA.

Thank you

Stop From Being Able To Backspace In A Textbox
Hi all,
Was wondering if anyone knew a way that if a certain character is before the current text cursor position, if that character is before (to the left) of the text cursor and the user presses backspace, if that character is there, if it is possible to stop the user from being able to continue to press back space. E.g. I have a textbox and it says "New Function>" and the cursor is right next to (on the right) of that character '>'. Is there a way to stop the user from being able to continue to backspace chartacters in the textbox once the text cursor pos is before that character?

Thanks

Delete Usin Backspace
Text entered into a textbox gets placed in a variable and used in a SQL string when a command button is clicked. I have a clear button which sets the .text = "" and sString = "", which is fine, but my users want to clear the value by highlighting the text and pressing "Backspace" or "Delete". That clears the textbox, but not my variable. How do you set a variable = "" in response to a specific keyboard press?

Thank you in advance.

Carlco

Space, Backspace Question
Hi,
I still have my 26 Characters(a-z) and they all have the name "lblCharacter". All works perfectly now except that I need to add "Space" and "Backspace" and they both are also called "lblCharacter" and need to be dragged into the same "txtReceiveCharacters" like the others.
I tried a few if statements and I was wondering if there is an easier way for this.

Thank you very much once again
Andonny

'Start Dragging the Character
Private Sub lblCharacter_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

Select Case Button
Case vbLeftButton
plstrDragCharacter = lblCharacter(Index)
lblCharacter(Index).Drag vbBeginDrag
If Shift = 0 Then
plstrDragCharacter = lblCharacter(Index)
Else
plstrDragCharacter = UCase(lblCharacter(Index))
End If
End Select

End Sub

' drop the Character
Private Sub txtReceiveCharacters_DragDrop(Source As Control, X As Single, Y As Single)

txtReceiveCharacters = txtReceiveCharacters & plstrDragCharacter

End Sub

Backspace Function Problem
In my latest project there has to be a keyboard facility. I can get the letters and numbers working but i don't know the function that deletes the last character entered. Is there any other way then the Mid Function.

??implement Backspace With Keypress??
I'm just wondering how to erase the last character in a text box that is written to using the forms keypress procedure. Here is my code so far to enter characters into the textbox, ignore the mscomm commands:

Private Sub form_keypress(keyascii As Integer)

'if key pressed is letter
If ((keyascii >= 32) And (keyascii <= 126)) Then
Text1.SelText = Chr(keyascii)
sendstring = sendstring & Chr(keyascii)
'if key pressed if CR
ElseIf (keyascii = 13) Then
Text1.SelText = vbCrLf + "<<MESSAGE SENT>>" + vbCrLf
MSComm1.Output = sendstring
sendstring = ""
'if key pressed is backspace
ElseIf (keyascii = 8) Then

<<???????????>>

'if any other key pressed
Else
MsgBox "Invalid Entry"
End If

End Sub


I'm fairly new to VB and any help would be greatly apprieciated.
Thanks...

Prob With Backspace And Text
prob1

i ve add keycodes 1-9 on nine buttons and backspace and it made a lil problem when i try to type inside the text box, it types double.

eg. i type in 1 text box show 11
when i hit 2 after that it shows 2112


prob2
when i hit backspace inside the textbox the text flashy line thing goes to the front but it still removes the last number.

eg. "1234|" hit bkspc "|123" ( | is flasy line thin)

Copyright © 2005-08 www.BigResource.com, All rights reserved