back space button
-
Mittwoch, 8. August 2012 13:56
hi i have 2 form,
a keyboard form with buttons and a main form with textboxs
Dim KBForm As keyb = New keyb Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click ' tis is use to show my keyboard form KBForm.Show() End Subbelow is use to get text from buttons from keyboard form to main form's textbox
the textbox iis at main form
Private Sub textbox1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.GotFocus KBForm.CurrentControl = TextBox1 End Subbelow code is to link them together which i place it at the keyboard form
Dim _CurrentControl As TextBox Public Property CurrentControl() As TextBox Get Return _CurrentControl End Get Set(ByVal value As TextBox) _CurrentControl = value End Set End Property
below is buttons from keyboard form event
Private Sub Button11_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click _CurrentControl.Text &= CType(sender, Button).Text End Subhow do i make the text from the textbox to -1 when clicked?
above code only get the text from buttons and fill up to the textbox
Alle Antworten
-
Mittwoch, 8. August 2012 14:12
_CurrentControl.Text &= CType(sender, Button).Text
'i tried everything from _CurrentControl.Text &= CType(sender, Button).Text.length.tostring(-1)
text.length.remove(1)text.length.remove(-1)
text.length.blablablabla all no luck
if kept giving me random number,letters or with false text in the textbox'
-
Mittwoch, 8. August 2012 14:26
Hi,
Do you want the TextBox text to actually read as "-1" or are you trying to remove some of the text in the TextBox such as the last character?
If the TextBox Text is Computers
do you want to remove the last character so it reads as Computer
?
Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.
Installing VB6 on Windows 7
App Hub for Windows Phone & XBOX 360 developers.
- Bearbeitet John Anthony Oliver Mittwoch, 8. August 2012 14:29
-
Mittwoch, 8. August 2012 14:28
If _CurrentControl.Text > "" Then
_CurrentControl.Text.Substring(0, CurrentControl.Text.Length - 1)
End IfIf _CurrentControl.Text > "" Then
If currentControl.Text > "" Then
_CurrentControl.Text.Substring(0, _CurrentControl.Text.Length - 1)
End If
CurrentControl.Text.Substring(0, CurrentControl.Text.Length - 1)
End Ifall no luck
-
Mittwoch, 8. August 2012 14:32
Hi,
You need to assign the result with an "="
If _CurrentControl.Text.Length >= 1 Then
CurrentControl.Text = CurrentControl.Text.Substring(0, CurrentControl.Text.Length - 1)
CurrentControl.Refresh()
End If
Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.
Installing VB6 on Windows 7
App Hub for Windows Phone & XBOX 360 developers.
- Bearbeitet John Anthony Oliver Mittwoch, 8. August 2012 14:34
- Bearbeitet John Anthony Oliver Mittwoch, 8. August 2012 14:35 Added Refresh statement, just in case. :)
- Als Antwort markiert newbieinVB Mittwoch, 8. August 2012 16:34
-
Mittwoch, 8. August 2012 15:03
I think I understood the description, but not the question "how do i make the text from the textbox to -1 when clicked?". Oh, looking at the subject line, you want to remove a character from the Textbox. Handling the backspace key is not that simple because it depends on the location of the caret within the string and the selected text in the textbox. I think this should do it:
Dim SelStart = _CurrentControl.SelectionStart
If _CurrentControl.SelectionLength = 0 Then If SelStart > 0 Then _CurrentControl.Text = _CurrentControl.Text.Remove(SelStart - 1, 1) _CurrentControl.SelectionStart = SelStart - 1 End If Else _CurrentControl.Text = _CurrentControl.Text.Remove(SelStart, _CurrentControl.SelectionLength) _CurrentControl.SelectionStart = SelStart End If
Armin
- Bearbeitet Armin Zingler Mittwoch, 8. August 2012 15:05 optimized
- Als Antwort markiert newbieinVB Mittwoch, 8. August 2012 16:34
-
Mittwoch, 8. August 2012 16:32i wan to remove last character of the text. or remove a character from textbox. either way is fine for me.i will try it out
-
Mittwoch, 8. August 2012 16:36
thanks all. i tried both solution and both give me wat i wanted.
really thanks

