Give up time! After nearly 2 days I can't figure why an Access Textbox is behaving strangely.
I'm pasting some text in and using the keydown event to reformat that text.
The form has one textbox only and its Enter key property is set to newline. Code is
When the form opens I click on the 4th line (the first blank one) and paste in 43_028d Joe Loss & His Orchestra (HMV BD 5816) and hit enter.
Why (after it reformats the pasted line as instructed ) does it then add a new line at the start of the textbox?
Printing Asc(text0) shows its 97 which is not a linefeed.
I'm pasting some text in and using the keydown event to reformat that text.
The form has one textbox only and its Enter key property is set to newline. Code is
Code:
Private Sub Form_Load()
Text0 = "a) Hutch (HMV BD 1054)" & vbCrLf
Text0 = Text0 & "b) Ambrose & His Orchestra v/Anne Shelton (Decca F 8344)" & vbCrLf
Text0 = Text0 & "c) Turner Layton (Columbia FB 2901)" & vbCrLf
End Sub
Private Sub text0_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Dim a As Variant, Dat As String
a = Split(CRTrim3(Text0.Text), vbCrLf)
Dat = a(UBound(a))
If InStr(Dat, "_") > 0 Then
Dat = Mid(Dat, 7)
Dat = Replace(Dat, " ", ") ", 1, 1)
Dat = Replace(Dat, " (", " (", 1, 1)
a(UBound(a)) = Dat
With Me
.Text0.Text = "" 'This shouldn't be necessary
.Text0.Text = Join(a, vbCrLf)
End With
End If
End If
End Sub
Private Function CRTrim3(ByVal c) As String
'Remove any tailing crlf from c
If Len(c) > 0 Then
Do
Select Case Asc(Right(c, 1))
Case 13, 10
c = Left(c, Len(c) - 1)
Case Else
Exit Do
End Select
Loop Until Len(c) = 0
End If
When the form opens I click on the 4th line (the first blank one) and paste in 43_028d Joe Loss & His Orchestra (HMV BD 5816) and hit enter.
Why (after it reformats the pasted line as instructed ) does it then add a new line at the start of the textbox?
Printing Asc(text0) shows its 97 which is not a linefeed.