美の谋略:VB程序的问题
来源:百度文库 编辑:中科新闻网 时间:2024/04/29 04:14:33
If(StrComp(Text2.Text, Text3.Text))=Ture Then
“这里要怎样写?”“注:我想要两个TextBox里面的相同内容显示在Text4里”
End If
谢谢了
StrComp()为真时,两个比较的内容是不同的吧?所以你要相同的内容就要在StrComp()=false时候了.
If(StrComp(Text2.Text, Text3.Text))=false Then
text4.text=text2.text
End If
如果Text2.Text, Text3.Text里的内容并不完全相同,而你想把Text2.Text, Text3.Text里面相同的内容取出的话,这个函数是不行的.
strcomp 函数
返回一个表明字符串比较结果的值。
strcomp(string1, string2[, compare])
参数
string1
必选项。任意有效的字符串表达式。
string2
必选项。任意有效的字符串表达式。
compare
可选项。指示在计算字符串时使用的比较类型的数值。如果省略,则执行二进制比较。有关数值,请参阅“设置”部分。
设置
compare 参数可以有以下值:
常数 值 描述
vbbinarycompare 0 执行二进制比较。
vbtextcompare 1 执行文本比较。
返回值
strcomp 函数有以下返回值:
如果 strcomp 返回
string1 小于 string2 -1
string1 等于 string2 0
string1 大于 string2 1
string1 或 string2 为 null null
说明
下面的示例利用 strcomp 函数返回字符串比较的结果。如果第三个参数为 1 执行文本比较;如果第三个参数为 0 或者省略执行二进制比较。
dim mystr1, mystr2, mycomp
mystr1 = "abcd": mystr2 = "abcd" 定义变量。
mycomp = strcomp(mystr1, mystr2, 1) 返回 0。
mycomp = strcomp(mystr1, mystr2, 0) 返回 -1。
mycomp = strcomp(mystr2, mystr1) 返回 1。