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.
The cut off 'Le...' was Length.
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.
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