dim i as integer dim temp1 as string dim temp2 as string on error resume next for i=0 to ubound(split(text1,vbcrlf)) if split(text1,vbcrlf)(i)<>split(text2,vbcrlf)(i) then temp1=temp1 & split(text1,vbcrlf)(i) & vbcrlf endif next i for i=0 to ubound(split(text2,vbcrlf)) if split(text2,vbcrlf)(i)<>split(text1,vbcrlf)(i) then temp2=temp2 & split(text2,vbcrlf)(i) & vbcrlf endif next i text1=temp1 text2=temp2
每一行都有自己的项号item的,可以做比较呀,给你删除的算法吧 Public Sub gLstDelItem(lstCtrl As Control, ByVal delIndex As Integer) If Not (TypeOf lstCtrl Is ListBox Or TypeOf lstCtrl Is ComboBox) Then Exit Sub End If
If lstCtrl.ListCount > 0 And delIndex >= 0 Then lstCtrl.RemoveItem delIndex
If lstCtrl.ListCount > 0 Then If lstCtrl.ListCount <= delIndex Then lstCtrl.ListIndex = delIndex - 1 Else lstCtrl.ListIndex = delIndex End If
End If End If End Sub
夏雪能不能请你把 for i=0 to ubound(split(text1,vbcrlf)) if split(text1,vbcrlf)(i)<>split(text2,vbcrlf)(i) then temp1=temp1 & split(text1,vbcrlf)(i) & vbcrlf endif next i 这段代码解释一下 谢了!
dim temp1 as string
dim temp2 as string
on error resume next
for i=0 to ubound(split(text1,vbcrlf))
if split(text1,vbcrlf)(i)<>split(text2,vbcrlf)(i) then
temp1=temp1 & split(text1,vbcrlf)(i) & vbcrlf
endif
next i
for i=0 to ubound(split(text2,vbcrlf))
if split(text2,vbcrlf)(i)<>split(text1,vbcrlf)(i) then
temp2=temp2 & split(text2,vbcrlf)(i) & vbcrlf
endif
next i
text1=temp1
text2=temp2
Public Sub gLstDelItem(lstCtrl As Control, ByVal delIndex As Integer)
If Not (TypeOf lstCtrl Is ListBox Or TypeOf lstCtrl Is ComboBox) Then
Exit Sub
End If
If lstCtrl.ListCount > 0 And delIndex >= 0 Then
lstCtrl.RemoveItem delIndex
If lstCtrl.ListCount > 0 Then
If lstCtrl.ListCount <= delIndex Then
lstCtrl.ListIndex = delIndex - 1
Else
lstCtrl.ListIndex = delIndex
End If
End If
End If
End Sub
for i=0 to ubound(split(text1,vbcrlf))
if split(text1,vbcrlf)(i)<>split(text2,vbcrlf)(i) then
temp1=temp1 & split(text1,vbcrlf)(i) & vbcrlf
endif
next i
这段代码解释一下
谢了!
如果用split(text1),默认是空格,好像是!
比如:text1="123 321 456" 那么执行temp=split(text1)结果是temp(1)="123" temp(2)="321" temp(3)="456"
ubound是用来测试数组的下限的,比如上面的数组temp用ubound(temp)得到的值是3
好像是这样的,如果没说清楚你去看看MSDN!
BYE-BYE