例如有个 关键字.txt
关键字.txt的内容为每行一个关键字
例如
你好
他好
....form1上有一文本框Text1,先在文本框Text1里输入一堆文字,然后点击Command1
如果文本框Text1的内容里包涵了 关键字.txt里的关键字 侧提示包涵关键字
关键字.txt的内容为每行一个关键字
例如
你好
他好
....form1上有一文本框Text1,先在文本框Text1里输入一堆文字,然后点击Command1
如果文本框Text1的内容里包涵了 关键字.txt里的关键字 侧提示包涵关键字
一行一行读 好像是 line input
然后比较instr,有就msgbox
Private Sub Command1_Click()
Open "c:\关键字.txt" For Binary As #1
Dim ct() As String, x
x = Trim(StrConv(InputB(LOF(1), 1), vbUnicode))
x = IIf(Right(x, 2) = vbCrLf, Left(x, Len(x) - 2), x)
ct = Split(x, vbCrLf)
Close #1
For Each x In ct
If InStr(Text1, x) Then
MsgBox "含关键字"
Exit For
End If
Next
End Sub
dim strline as string
open app.path+"\关键字.txt" for input as #1
do untile eof(1)
line input #1,strline
if intstr(trim(text1.text),trim(strline))>0 then msgbox "检测到关键字!":exit loop
loop
close #1
lz拿好.
Dim a As String
a=SunEditCtrl1.Text
'MsgBox a
If InStr(a,"123")>0 Then
SunEditCtrl2.Text ="123"
End If
End Sub
当SunEditCtrl1含有123 点击SunButtonCtrl1 123将自动进入SunEditCtrl2
千万别拿好,修正一下...看来还是脱不开编译器,悲剧..Dim strline As String
Open app.path+"\关键字.txt" For Input As #1
Do Until EOF(1)
Line Input #1, strline
If InStr(Trim(Text1.Text), Trim(strline)) > 0 Then MsgBox "检测到关键字!": Close #1: Exit Sub
Loop
Close #1
猴哥,我真欣赏你信手拈来,心中点豆的水平啊,IIF都用了,我表示从我学vb以来还没有过IIF