Vb basic -compare text between 2textbox

January 28, 2010 at 18:57:23
Specs: Windows XP
HAI...i work on VBS express edition and would like to compare text between 2 textbox.eg.:

textbox1:abcabc
textbox2:abc123

if there is any error(text not equal in text compare)then the error message will b display at another textbox.

would someone help me plz...thank u very2 much...


See More: Vb basic -compare text between 2textbox

Report •


#1
January 28, 2010 at 19:53:15
not sure about vbs express, but i know in visbasic 3.2 its simply:
if testbox1.text = textbox2.text then
textbox3.text="same"
else
textbox3.text="differ"
end if

Report •

#2
January 28, 2010 at 20:11:11
THANKS NBRANE for ur reply..but what i would like to do is :

1. i will read textbox1 character by character and same for textbox2 also..
2.then i will check wether 1st characters (in both textbox) are same or not.
3.if both 1st charactr are same,then i will go to the next character(for both textbox).
4.if both 1st character not same,i will dispaly "not same" sentence in textbox3 and mention which line does the error occur...(each textbox may have multiple line)

any help...(T__________T)


Report •

#3
January 28, 2010 at 21:30:10
I'm not sure why you need to do a byte-by-byte analysis of each box, but you might have good reasons. I used this to do a line-text analysis of lines from boxes:
crlf=chr(13)+chr(10)
dim k(2),line(2)
k(1)=textbox1.text
k(2)=textbox2.text
c=0
:aa
c=c+1
if k(1)="" and k(2)="" then goto done
for i=1 to 2 : gosub getline : next i
if line(1) = line(2) then goto aa
textbox3.text=textbox3.text+"lines not equal at line: ";str(c)+crlf
goto done

getline:
p=instr(k(i),crlf) : if p=0 then p=len(k(i))
line(i)=left(k(i),p-1)
k(i)=mid(k(i),p+2,32000)
return

done:
exit sub

if you have to do a single-byte compare, insert another
for-loop based on length of line(1) and setting byte to
mid(line(1),i,1) vs mid(line(2),i,1) till nonequal or end of forloop.
hthelps


Report •

Related Solutions

#4
January 29, 2010 at 01:38:35
thanks a lot nbrane~
(^_^)

Report •


Ask Question