Inserting character at Line 30 of multiline textbox

S

Silvester

Hi,

On my A2000 form I have a multiline textbox linked to a table memo field.

How can I locate line 30 and insert my own character marker say, [|] at the
beginning of line 31 ??

I have not been able to find this solution anywhere. Would some good guru
samaritan please help me out on this ?

Thanks in advance
 
A

Albert D. Kallal

You could use:

Dim lbuf As Variant

If IsNull(Me.Text0) = True Then
ReDim lbuf(1)
Else
lbuf = Split(Me.Text0, vbCrLf)
End If

If UBound(lbuf, 1) < 30 Then
ReDim Preserve lbuf(30)
End If

lbuf(30) = "|" & vbCrLf & lbuf(30)

Me.Text0 = Join(lbuf, vbCrLf)
 
S

Silvester

Thank you Albert. That worked excellent.

I would like to now check for the 1st occurence of a blank line (vbnewline &
vbnewline) nearest to line30 and insert the marker "[|]" at the end of this
'para'

Could you please help me with this.

Thanks again
 
A

Albert D. Kallal

Note that the data is pulled into an array with the split command.

So, if you are looking for a blank line, you can just start looking, and
test for the element = "" (ie: test for a empty string using lbuf(iPtr) =
"")

You don't mention which direction you want to search from line 30, but it
really don't matter. (just make your loop go down, or up, depending on which
way you want to search. That is your choice, not mine!). That should do the
trick.

So, use the array that you already loaded, as that makes things easy...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top