[AccessD] Simulate tab in a plain text textbox
Ryan W
wrwehler at gmail.com
Wed Apr 5 16:06:55 CDT 2023
Yes for now it’s for a single text box.
I did turn it into a sub so it could be used on different controls but I can’t see it happening for now.
I also quit tracking the tab count as in the end that made no sense. If they press tab I just increment lPos by 4 and then set the control SelStart to the new lPos
Sent from my iPhone
> On Apr 5, 2023, at 3:10 PM, John Colby <jwcolby at gmail.com> wrote:
>
> Is this a single instance scenario? Because if you need to save state and
> it is used in several text boxes you are asking for trouble.
>
>> On Mon, Apr 3, 2023, 21:48 Ryan W <wrwehler at gmail.com> wrote:
>>
>> Does anyone have some slick code to simulate pressing tab in a plain text
>> textbox?
>>
>> this is what I've got now:
>>
>> Option Compare Database
>> Option Explicit
>> Private lPos As Long
>> Private lTabCnt As Long
>>
>> Private Sub Narrative_KeyUp(KeyCode As Integer, Shift As Integer)
>> If KeyCode <> vbKeyTab Then
>> lPos = Me!Narrative.SelStart
>> lTabCnt = 0
>> End If
>> If KeyCode = vbKeyTab Then
>> Dim leftTxt As String, rightTxt As String, tabPOS As Long
>> KeyCode = 0
>> lTabCnt = lTabCnt + 1
>> tabPOS = lPos + (lTabCnt * 4)
>> leftTxt = left(Me!Narrative, lPos)
>> rightTxt = Mid(Me!Narrative, lPos + 1)
>> Me!Narrative = leftTxt & Space(4) & rightTxt
>> Me!Narrative.SelStart = tabPOS
>> End If
>> End Sub
>>
>> Private Sub Narrative_MouseUp(Button As Integer, Shift As Integer, X As
>> Single, Y As Single)
>> lPos = Me!Narrative.SelStart
>> End Sub
>>
>>
>> It seems to work for most scenarios, but it flashes as if I'm highlighting
>> the text when I press tab. Application.Echo and SetPainting have no
>> effect.
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> https://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list