Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Im writting a program that people can write into but i can\'t figure out how to

ID: 3631303 • Letter: I

Question

Im writting a program that people can write into but i can't figure out how to make the backspace accually back space instead of writting (backspace) into the text box. Normially i could use TextBox1.Text, 1, Len(TextBox1.Text) - 1, but the key grabbing code has to be in a class of it's own @_@ i don't know what to do, all i know is that the backspace is case 8

Public Class Keyboard
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal Hook As Integer, ByVal KeyDelegate As KDel, ByVal HMod As Integer, ByVal ThreadId As Integer) As Integer
'apendage
Private Declare Function CallNextHookEx Lib "user32" (ByVal Hook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KeyStructure) As Integer
'apendage
Private Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal Hook As Integer) As Integer
Private Delegate Function KDel(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As KeyStructure) As Integer
'apendage
Public Shared Event Down(ByVal Key As String)
Public Shared Event Up(ByVal Key As String)
'apendage
Private Shared Key As Integer
Private Shared KHD As KDel
Private Structure KeyStructure : Public Code As Integer : Public ScanCode As Integer : Public Flags As Integer : Public Time As Integer : Public ExtraInfo As Integer : End Structure
Public Sub CreateHook()
'apendage
KHD = New KDel(AddressOf Proc)
Key = SetWindowsHookEx(13, KHD, System.Runtime.InteropServices.Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
End Sub
'apendage
Private Function Proc(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KeyStructure) As Integer
If (Code = 0) Then
'apendage
Select Case wParam
Case &H100, &H104 : RaiseEvent Down(Feed(CType(lParam.Code, Keys)))
Case &H101, &H105 : RaiseEvent Up(Feed(CType(lParam.Code, Keys)))
End Select
'apendage
End If
Return CallNextHookEx(Key, Code, wParam, lParam)
End Function
Public Sub DiposeHook()
'apendage
UnhookWindowsHookEx(Key)
MyBase.Finalize()
End Sub
Private Function Feed(ByVal e As Keys) As String
'apendage
Select Case e

' Case 8 : Return


Case 65 To 90
If Control.IsKeyLocked(Keys.CapsLock) Or (Control.ModifierKeys And Keys.Shift) <> 0 Then
Return e.ToString
Else
'apendage
Return e.ToString.ToLower
End If
Case 48 To 57
If (Control.ModifierKeys And Keys.Shift) <> 0 Then
Select Case e.ToString
Case "D1" : Return "!"
'apendage
Case "D2" : Return "@"
Case "D3" : Return "#"
Case "D4" : Return "$"
Case "D5" : Return "%"
Case "D6" : Return "^"
Case "D7" : Return "&"
'apendage
Case "D8" : Return "*"
Case "D9" : Return "("
Case "D0" : Return ")"
End Select
Else
Return e.ToString.Replace("D", Nothing)
End If
Case 96 To 105
Return e.ToString.Replace("NumPad", Nothing)
'apendage
Case 106 To 111
Select Case e.ToString
Case "Divide" : Return "/"
Case "Multiply" : Return "*"
Case "Subtract" : Return "-"
Case "Add" : Return "+"
'apendage
Case "Decimal" : Return "."
End Select
Case 32
Return " "
Case 186 To 222
If (Control.ModifierKeys And Keys.Shift) <> 0 Then
Select Case e.ToString
Case "OemMinus" : Return "_"
Case "Oemplus" : Return "+"
Case "OemOpenBrackets" : Return "{"
'apendage
Case "Oem6" : Return "}"
Case "Oem5" : Return "|"
Case "Oem1" : Return ":"
Case "Oem7" : Return """"
Case "Oemcomma" : Return "<"
Case "OemPeriod" : Return ">"
Case "OemQuestion" : Return "?"
Case "Oemtilde" : Return "~"
End Select
Else
Select Case e.ToString
Case "OemMinus" : Return "-"
'apendage
Case "Oemplus" : Return "="
Case "OemOpenBrackets" : Return "["
Case "Oem6" : Return "]"
Case "Oem5" : Return ""
Case "Oem1" : Return ";"
Case "Oem7" : Return "'"
Case "Oemcomma" : Return ","
Case "OemPeriod" : Return "."
Case "OemQuestion" : Return "/"
Case "Oemtilde" : Return "`"
End Select
End If
Case Keys.Return
Return Environment.NewLine
Case Else
'apendage
Return "<" + e.ToString + ">"
End Select
Return Nothing
End Function
End Class

Explanation / Answer

Ok rate this as lifesaver first. I am sick and tired of people taking advantage of me. I spend 30 minutes to one hour posting a solution and then they just take the answer and dont rate it. Inbox me once you have rated it and I will send you the solution.