Visual Basic 2010 calculator help?

I'm making a calculator from Visual Basic 2010 but i couldn't quite get things going as i hoped. I'm trying to get the backspace button working so that it deletes the last digit (ones column).
I'm not sure why it isn't working but here's my code:
Dim str As String
str = lblDisplay.Text.Chars(lblDisplay.Text.Length - 1)
lblDisplay.Text = str
It gets rid off all the digits besides the last one (ones column) and this is really starting to fustrate me.

Any help would be appreciated, thanks.

2011-03-03T01:32:41Z

The cut off 'Le...' was Length.

2011-03-03T23:25:59Z

texasmaverick, no the code doesn't work.

Gardener the code works but if you try backspace until it ends up with no text and press backspace once more the program crashes. Going to try work that out but if you find it before please post it up.

2011-03-03T23:30:12Z

Don't worry i got it, code was:

Dim str As String
str = lblDisplay.Text
lblDisplay.Text = str.Substring(1, str.Length - 1)
If lblDisplay.Text = "" Then
lblDisplay.Text = "0"
End If

Gardner2011-03-03T01:32:58Z

Favorite Answer

Yahoo kind of chopped up your code there. Can't read it.

Edit:

You might try something like this:
Dim str As String
str = lblDisplay.Text
lblDisplay.Text = str.Substring(1,str.Length - 1)

Personally though I would just make the label a textbox and add in some code in the keypress event handler to make sure no letters got entered.

texasmaverick2011-03-03T05:35:23Z

Try replacing the two lines in question with the following code:

str=lblDisplay.Text
lblDisplay.Text=Left(str,Len(str)-1)

This might work. It is some of the earlier versions of VB code.

cracchiolo2016-10-06T17:33:44Z

Documentation for seen easy is freely obtainable from Microsoft on the MSDN internet site. BTW, people who use the term "aspects codes" are recognized as glaring beginners and not taken heavily. "source code" is the uncompiled programming training. The term "source codes" means that there is a few "secret code" to programming or some such nonsense.