Hi folks,
I need help with creating a right-to-left Text Box control. This text box is for a language that unlike English is written from right to left. So in this text box,
you should be able to
- write from right to left
- when Enter key is pressed, the insertion point should go down to the next line on the right side.
- when the Backspace key is pressed, the insertion point should backspace and delete text from left to right, unlike in normal Text Box.
I have been able to come up with something(below, also attached). It works fine but has some problems namely
-when Backspace key is pressed, the Backspace behaves as it does in normal text box, I want the opposite of that, that is to delete from left-to-right.
-when I go to the second, third etc. line and come back to the first line. It does not behave as I expect.
Your help and time to resolve this problem will be appreciated. Thanks a lot.
Regards
Private lStart As Long
Private Sub txtEdit_KeyPress(KeyAscii As Integer)
txtEdit.SelStart = lStart
If KeyAscii = 13 Then 'if Enter key is pressed
'Label1.Caption = "Enter Pressed"
'This function is called before the character is added
'to the textbox so if we want to find out the total
'length we need to manually add our break and then count.
txtEdit.Text = txtEdit.Text & vbCrLf
lStart = Len(txtEdit.Text)
txtEdit.SelStart = lStart
'Since we already added our CRLF, we don't want to add it
'again so set KeyAscii to 0
KeyAscii = 0
End If
End Sub
I need help with creating a right-to-left Text Box control. This text box is for a language that unlike English is written from right to left. So in this text box,
you should be able to
- write from right to left
- when Enter key is pressed, the insertion point should go down to the next line on the right side.
- when the Backspace key is pressed, the insertion point should backspace and delete text from left to right, unlike in normal Text Box.
I have been able to come up with something(below, also attached). It works fine but has some problems namely
-when Backspace key is pressed, the Backspace behaves as it does in normal text box, I want the opposite of that, that is to delete from left-to-right.
-when I go to the second, third etc. line and come back to the first line. It does not behave as I expect.
Your help and time to resolve this problem will be appreciated. Thanks a lot.
Regards
Private lStart As Long
Private Sub txtEdit_KeyPress(KeyAscii As Integer)
txtEdit.SelStart = lStart
If KeyAscii = 13 Then 'if Enter key is pressed
'Label1.Caption = "Enter Pressed"
'This function is called before the character is added
'to the textbox so if we want to find out the total
'length we need to manually add our break and then count.
txtEdit.Text = txtEdit.Text & vbCrLf
lStart = Len(txtEdit.Text)
txtEdit.SelStart = lStart
'Since we already added our CRLF, we don't want to add it
'again so set KeyAscii to 0
KeyAscii = 0
End If
End Sub