求一个文本比较的Function

kenways 2006-02-20 08:46:45
FORM中有16个TEXTBOX,输入资料后当不为空内容的文本则要进行互相比较,使各个TEXTBOX的内容都不是一样的,如果检测到有相同的内容时就提示并且内容所在的TEXTBOX就focus
...全文
82 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengyaner 2006-02-21
  • 打赏
  • 举报
回复
楼上的可以
夜雨悠扬 2006-02-20
  • 打赏
  • 举报
回复
不好意思刚才有个地方有点问题就是a(i)=Ctype(d.TextBox).Text 不应该是a(i) 而应该是a(j)
dim a(16) as String
dim j as integer =0
For Each d As Control In Me

If TypeOf d is TextBox then
dim i =0
for i =0 to 16
if a(i)=Ctype(d.TextBox).Text then
Ctype(d.TextBox).foucs()
return false
End if
next i
if i=16 then
a(j)=Ctype(d.TextBox).Text
end if
j+=1
End IF
Next
reutrn true
End Function
夜雨悠扬 2006-02-20
  • 打赏
  • 举报
回复
Public Function CHeckValue() As Boolean
dim a(16) as String
For Each d As Control In Me
If TypeOf d is TextBox then
dim i =0
for i =0 to 16
if a(i)=Ctype(d.TextBox).Text then
Ctype(d.TextBox).foucs()
return false
End if
next i
if i=16 then
a(i)=Ctype(d.TextBox).Text
end if
End IF
Next
reutrn true
End Function

你可以稍稍扩展一下,就可以判断出那些TextBox中有值,那些是空的。
sanjie88 2006-02-20
  • 打赏
  • 举报
回复
Public Function CHeckValue(ByVal Tlist As TextBox()) As Integer
For d As Integer = 0 To Tlist.Length
Dim CurrText As TextBox = Tlist(d)
If Trim(CurrText.Text).Length > 0 Then
For i As Integer = 0 To Tlist.Length
Dim compText As TextBox = Tlist(i)
If i <> d Then
If compText.Text.Trim.Length > 0 Then
If String.Compare(compText.Text, CurrText.Text) <> 0 Then
Return i
End If
End If
End If
Next
End If
Next
End Function
那个数组就你自己做了,这样应该能用

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧