Tuesday, May 5, 2009

How to code BackSpace button in Calculator?

I have a problem with backspace button in digital calculator.....

25 comments:

  1. The Backspace button involves Mid function as

    'If we have no characters in textbox then it should not execute the code

    If Len(Text1.Text) = 0 Then Exit Sub
    ' Now remove the last character from the textbox

    Text1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)

    ReplyDelete
  2. MOTHERFUCKERS , DO YOU KNOW WHAT IS "BACKSPACE" ? I WANT THE CODE OF BACKSPACE TO KEYBOARD VIRTUAL , TO VISUAL BASIC , I TRIE THE SHIT THAT YOU PUT ON THIS SITE , YOU MOTHER IN 4.

    ReplyDelete
  3. Thanks, very helpful. Works perfectly. (Remember to replace where it says Text1 to whatever the name of your output textbox is.

    ReplyDelete
  4. what about equal sign of calculator

    ReplyDelete
  5. 'I have used the following code'
    'which works perfectly in my application '
    'Thank you for giving me the insight of the Mid function'

    If TextBox1.Text.Length > 1 Then
    TextBox1.Text=Mid(TextBox1.Text,1, Len(TextBox1.Text)-1)
    ElseIf TextBox1.Text.Length = 1 Then
    TextBox1.Text = 0
    Else
    Exit Sub
    End If

    ReplyDelete
  6. If display.Text.Length = 1 Then
    display.Text = Mid(display.Text, 1, Len(display.Text) - 1)
    display.Text = 0
    Else
    display.Text = Mid(display.Text, 1, Len(display.Text) - 1)
    End If

    ReplyDelete
  7. Private Sub btnBackSpace_Click_1(sender As Object, e As EventArgs) Handles btnBackSpace.Click

    'The procedure works as a backspace for the
    'cash box

    If txtCash.Text < " " Then

    txtCash.Text = Mid(txtCash.Text, 1, Len(txtCash.Text) - 1 + 1)

    Else

    txtCash.Text = Mid(txtCash.Text, 1, Len(txtCash.Text) - 1)

    End If

    End Sub

    ReplyDelete
    Replies
    1. I have used this code working well but problem is here when we two textboxes one for English and other urdu and button from arabic script urdu language character having "Chy" character equil in English "ch" I face problem here

      Delete
    2. I have used this code working well but problem is here when we two textboxes one for English and other urdu and button from arabic script urdu language character having "Chy" character equil in English "ch" I face problem here

      Delete
  8. If Len(TextBox1.Text) > 1 Then
    TextBox1.Text = Left(TextBox1.Text, Len(TextBox1.Text) - 1)
    ElseIf Len(TextBox1.Text) = 1 Then
    TextBox1.Text = 0
    Else
    Exit Sub
    End If

    ReplyDelete
  9. Do this it will guarenteed work:
    If Len(TextBox1.Text) <> 0 Then
    TextBox1.Text = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 1)
    End If

    ReplyDelete
    Replies
    1. doesn't work, it deletes the number but when I click a new number to replace, it just comes back.
      Ex.
      987, 'deletes 7
      Answer.Text = 98
      'Adds 6
      Answer.Text = 9876

      Delete