vb如何比較兩個文字框內容,請問VB中怎麼對兩個文字框的文字進行比較,不一樣的用紅色來表示?

2022-03-15 00:29:04 字數 5532 閱讀 3196

1樓:匿名使用者

在每次text2換行時進行檢測(就是按下回車鍵時),**如下

private sub text2_keydown(keycode as integer, shift as integer)

dim lngcrlf as string

if keycode = vbkeyreturn then

lngcrlf = instrrev(text2.text, vbcrlf)

if lngcrlf > 0 then

if mid(text2.text, lngcrlf + 2, len(text2.text)) = text1.text then msgbox "與text1一樣"

elseif lngcrlf = 0 then

if text2.text = text1.text then msgbox "與text一樣"

end if

end if

end sub

private sub form_load()

text1.text = "112233"

text2.text = ""

end sub

2樓:匿名使用者

aa=split(text2,vbcrlf)for i=0 to ubound(aa)if aa(i)=text1 then msgbox"第" & i+1 & "行相同"

next

3樓:匿名使用者

文字框有個change事件,當發生變化時,判斷一下是否一樣就可以了.

請問vb中怎麼對兩個文字框的文字進行比較,不一樣的用紅色來表示?

4樓:華仔成教

普通文字框不能區域性變色,請使用 richtext(工程--部件--選擇:microsoft rich textbox control...)

5樓:匿名使用者

if len(richtext1.text)<>len(richtext2.text) then msgbox "兩邊字數不等":exit sub

for n=1 to len(richtext1.text)v=mid(richtext1.text,n,1)vv=mid(richtext2.

text,n,1)if v<>vv then

richtext1.selstart = nrichtext1.sellength = 1richtext1.

selcolor = vbredrichtext2.selstart = nrichtext2.sellength = 1richtext2.

selcolor = vbredend if

next

vb怎樣比較文字內容?

6樓:匿名使用者

你的段**不是同行比較,是乙個檔案中的凡是在第二個檔案中有重複的行寫到新檔案中。

用vb如何把兩個文字框的內容按一定格式合併成乙個文字框?

7樓:匿名使用者

超級簡單

1、新增三個text控制項,text1 text2和text3,並且把multiline屬性設為true,注意:三個都要設為true

2.新增乙個command控制項,command1

3、複製**進去執行

private sub command1_click()

dim temp1() as string

dim temp2() as string

temp1() = split(text1.text, vbcrlf)

temp2() = split(text2.text, vbcrlf)

for i = 0 to ubound(temp1)

text3.text = text3.text & temp1(i) & ":" & temp2(i) & vbcrlf

next i

end sub

private sub form_load()

text1.text = "北京" & vbcrlf & "上海" & vbcrlf & "天津"

text2.text = "1號" & vbcrlf & "2號" & vbcrlf & "3號"

command1.caption = "合併"

end sub

vb如何使兩個(或以上的)文字框顯示相同的內容

8樓:

使用change方法

這個是當文字改變時候發生的

private sub text1_change()dim wen as string

wen=text1.text

text2.text = wen

end sub

反正就是當text1發生改變時候,text1的內容傳到text2我也是剛學的,不知道錯沒

9樓:匿名使用者

監測哪個文字框在改變,就用哪個文字的change事件private sub text1_change()text2 = text1

text3 = text1

'...

end sub

vb如何讓兩個程式的文字框內容一樣

10樓:匿名使用者

參考這個**

private declare function findwindow lib "user32" alias "findwindowa" (byval lpclassname as string, byval lpwindowname as string) as long

private declare function findwindowex lib "user32" alias "findwindowexa" (byval hwnd1 as long, byval hwnd2 as long, byval lpsz1 as string, byval lpsz2 as string) as long

private declare function sendmessage& lib "user32" alias "sendmessagea" (byval hwnd as long, byval wmsg as long, byval wparam as long, lparam as any)

private sub command1_click()

dim h1 as long

dim h2 as long

h1 = findwindow(vbnullstring, "form1") 'form1是要填入資料的視窗的標題

if h1 <> 0 then

h2 = findwindowex(h1, h2, "thunderrt6textbox", vbnullstring)

h2 = findwindowex(h1, h2, "thunderrt6textbox", vbnullstring)

h2 = findwindowex(h1, h2, "thunderrt6textbox", vbnullstring)

h2 = findwindowex(h1, h2, "thunderrt6textbox", vbnullstring)

h2 = findwindowex(h1, h2, "thunderrt6textbox", vbnullstring)

end if

end sub

11樓:鉛筆

沒太看懂你說的文字框4是什麼意思

1.放置乙個按鈕 command1

2.放置6個文字框,分別為左面3個 text1 text2 text3 右面3個為 text4 text5 text6

3.清空所有**,然後複製下面**,開始後點選按鈕,右面的文字框內容就會和左邊的一樣了

private sub command1_click()text4.text = text1.texttext5.

text = text2.texttext6.text = text3.

textend sub

private sub form_load()text1.text = "你好"

text2.text = "我們"

text3.text = "hello"

end sub

12樓:

首先你說的兩個程式是兩個獨立的程式還是乙個程式中的兩個窗體。如果是前者,就需要利用抓取兩個程式的控制代碼,然後用相關的api程式實現。如果是乙個程式中的兩個窗體,那太簡單了。。

由於無法確定你的兩個程式的相關資訊,所以就不好寫**,請提供更為詳細的資訊。。。

13樓:excel實用文件

要不用乙個word**或excel做中介,我程式一中文字框1,文字框2,文字框3,文字框4的text值,寫入中介中 ,程式二再從中介中讀取。這樣就不會亂了吧

用vb怎麼實現兩個檔案內容的比較

14樓:匿名使用者

只能說個原理給你:

以二進位制的方式讀出兩個檔案,分別儲存到記憶體中。

再用迴圈語句,對每個位元組進行比較。

vb中的文字框內容對比

15樓:亂刀_斬快麻

dim a as string 'a 是text1的預設值private sub command1_click()dim i as integer

for i = 1 to len(text1.text)if left(a, i) <> left(text1.text, i) then msgbox "第" & i & "位錯誤"

next i

end sub

private sub form_load()a = "qwer"

end sub

直接貼上複製可用,增加其他text 方法參考text1的寫法sorry 寫錯了

dim a as string 'a 是text1的預設值private sub command1_click()dim i as integer

for i = 1 to len(text1.text)if mid(a, i, 1) <> mid(text1.text, i, 1) then msgbox "第" & i & "位錯誤"

next i

end sub

private sub form_load()a = "qwer"

end sub

VB文字框內容清空再顯示下一條,將兩個文字框內容清空,單擊窗體後定位游標在文字框2,實現文字框1寫什麼,文字框2就顯什麼,用VB怎麼編呀

dim i as integer,j as integer dim a 100,100 as integer private sub command1 click text1.text 清空顯示楊輝三角文字框 w cdbl text2.text for i 0 to w 1 a i,i 1 a i,...

vb如何將print的內容改到文字框tet1中顯示

text1 共有以上 l 組。vb練習 現了問題 怎麼做才能將內容用print語句輸出到textbox中 private sub command1 click print 無法在文字框中輸出,下面方法可以實現在文字框中輸出 dim x as integer x 401 if x mod 4 0 an...

ai兩個文字框的落段文字自動連線

天雲 你想問的是什麼,這個你可以再畫一個矩形,然後點文字那裡有一個紅色的加號,再點你畫的那個矩形就可以了 怎麼看軟體用哪種程式語言寫的 編譯工具通常會有符串編入dll或exe檔案中,用文字編輯器開啟後搜相應字串即可,如delphi,visual c basic等 w東方欲曉 一般用 peid ffi...