VB Text1 Text2内容对比

来源:百度知道 编辑:UC知道 时间:2024/06/22 00:26:56
控件:
text1 text2
command1

点击COMMAND1后将文本1和文本2 里面的内容对比 找出差异 然后用某种方法让我知道 它们的差异

private sub command_click()
dim R1 as string,R2 as string,i as integer
r1=text1.text
r2=text2.text
if len(r1)<>len(r2) then
msgbox "长度不同!"
exit sub
else
for i=1 to len(r1)
if mid(r1,i,1)<>mid(r2,i,1) then
msgbox "第"+str(i)+"个字符不同!"
end if
next i
end if
end sub

楼上的代码被我修改了一下。。