回复 15楼 吹水佬
楼主的要求还要考虑有硬回车换行的问题。
添加处理前后硬回车换行
程序代码:
of = CREATEOBJECT("_Form")
of.Show(1)
RETURN
DEFINE CLASS _Form AS Form
ADD OBJECT Cmd1 AS CommandButton WITH Top=10,Left=10,Height=25,Caption="开始"
ADD OBJECT Edit1 AS EditBox WITH Top=50,Left=10,Height=100,HideSelection=.F.
ADD OBJECT Edit2 AS EditBox WITH Top=155,Left=10,Height=100,Width=200
PROCEDURE Edit1.Init
this.Value = "12345678901"+0h0D0A+"23456789012345"+0h0A+"6789012345678"+0h0D+"901234567890"
ENDPROC
PROCEDURE Cmd1.RightClick
thisform.Edit1.Value = "12345678901"+0h0D0A+"23456789012345"+0h0A+"6789012345678"+0h0D+"901234567890"
thisform.Edit2.Value = ""
ENDPROC
PROCEDURE Cmd1.Click
thisform.edit1.SetFocus
DO WHILE !EMPTY(thisform.Edit1.Value)
IF (SUBSTR(thisform.Edit1.Value, 1, 2) == 0h0D0A)
thisform.Edit1.Value = SUBSTR(thisform.Edit1.Value, 3)
thisform.Edit2.SelText = 0h0D0A
LOOP
ENDIF
IF INLIST(SUBSTR(thisform.Edit1.Value, 1, 1), 0h0D, 0h0A)
thisform.Edit1.Value = SUBSTR(thisform.Edit1.Value, 2)
thisform.Edit2.SelText = 0h0D0A
LOOP
ENDIF
thisform.Edit1.SelStart = 0
KEYBOARD "{SHIFT+END}" CLEAR
DO WHILE thisform.Edit1.SelLength < 1
DOEVENTS
ENDDO
ss = thisform.Edit1.SelText
IF !EMPTY(ss)
thisform.Edit2.SelText = ss + 0h0D0A
ENDIF
thisform.Edit1.Value = SUBSTR(thisform.Edit1.Value, LEN(ss)+1)
IF (SUBSTR(thisform.Edit1.Value, 1, 2) == 0h0D0A)
thisform.Edit1.Value = SUBSTR(thisform.Edit1.Value, 3)
ENDIF
IF INLIST(SUBSTR(thisform.Edit1.Value, 1, 1), 0h0D, 0h0A)
thisform.Edit1.Value = SUBSTR(thisform.Edit1.Value, 2)
ENDIF
ENDDO
ENDPROC
ENDDEFINE