Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right-to-left Text Box Control??

Status
Not open for further replies.

szewari

Technical User
Jan 8, 2004
1
US
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
 
Visual Basic has support for other languages that need special ways of writting text and that kind of stuff check the MSDN documentation cd's that come with VB for more info.
 
If this app is to run on a platform that supports Right to Left script (such as Arabic or Hebrew) then check out the RightToLeft Property in VBHelp

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top