根粗迟据文本框是否选择文字,即Text1.SelLength > 0,还能根据选中的文字激活,代码如下:
'添加Text1,Command1,Timer1三个控件
Private Sub 手拿form_Load()
Timer1.Interval = 200
Command1.Enabled = False
Text1 = "特定的字符"
End Sub
Private Sub Timer1_Timer()
If Text1.SelLength > 0 Then '文本框是否选择文字
If Mid(Text1, Text1.SelStart + 1, Text1.SelLength) = "特定" Then '毕凳搭根据选中的文件激活
Command1.Enabled = True
End If
End If
End Sub
运行时:
选择 特定 这两个字符,激活:
if textbox.focused = true then
button.Enabled = true
else
button.Enabled = false
endif
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Text1.SelLength = Len(Text1.Text) Then
Me.Command1.Enabled = True
End If
End Sub
private sub form_Load()
command1.enabled=false
end sub
Private Sub Text1_change()
If Text1.SelLength <态明伏>帆携槐穗0 Then
Command1.Enabled = True
End If
End Sub