我在MSDN查SelStart属性时看到的一个例子,源码如下:Example
The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.Private Sub Form_Load()
Dim ctlTextToSearch As Control
Set ctlTextToSearch = Forms!Form1!Textbox1
' SetFocus to text box.
ctlTextToSearch.SetFocus
ctlTextToSearch.Text = "This company places large orders twice " & _
"a year for garlic, oregano, chilies and cumin."
Set ctlTextToSearch = Nothing
End SubPublic Sub Find_Click()
Dim strSearch As String
Dim intWhere As Integer
Dim ctlTextToSearch As Control
' Get search string from user.
With Me!Textbox1
strSearch = InputBox("Enter text to find:")
' Find string in text.
intWhere = InStr(.Value, strSearch)
If intWhere Then
' If found.
.SetFocus
.SelStart = intWhere - 1
.SelLength = Len(strSearch)
Else
' Notify user.
MsgBox "String not found."
End If
End With
End Sub'\\\\以下3句我不懂:'1.Dim ctlTextToSearch As Control
'2.Set ctlTextToSearch = Forms!Form1!Textbox1
'3.With Me!Textbox11.可以直接定义为Control类型吗?这样有什么好处?
2. 3. 请问这两句表示什么意思,那个“!”运算符是起什么作用?小第初学,起各位帮忙!
The following example uses two event procedures to search for text specified by a user. The text to search is set in the form's Load event procedure. The Click event procedure for the Find button (which the user clicks to start the search) prompts the user for the text to search for and selects the text in the text box if the search is successful.Private Sub Form_Load()
Dim ctlTextToSearch As Control
Set ctlTextToSearch = Forms!Form1!Textbox1
' SetFocus to text box.
ctlTextToSearch.SetFocus
ctlTextToSearch.Text = "This company places large orders twice " & _
"a year for garlic, oregano, chilies and cumin."
Set ctlTextToSearch = Nothing
End SubPublic Sub Find_Click()
Dim strSearch As String
Dim intWhere As Integer
Dim ctlTextToSearch As Control
' Get search string from user.
With Me!Textbox1
strSearch = InputBox("Enter text to find:")
' Find string in text.
intWhere = InStr(.Value, strSearch)
If intWhere Then
' If found.
.SetFocus
.SelStart = intWhere - 1
.SelLength = Len(strSearch)
Else
' Notify user.
MsgBox "String not found."
End If
End With
End Sub'\\\\以下3句我不懂:'1.Dim ctlTextToSearch As Control
'2.Set ctlTextToSearch = Forms!Form1!Textbox1
'3.With Me!Textbox11.可以直接定义为Control类型吗?这样有什么好处?
2. 3. 请问这两句表示什么意思,那个“!”运算符是起什么作用?小第初学,起各位帮忙!
form1!cmd.caption"!"用于连接两个容器,且前者是后者的容器
看一段代码,将from中的所有text清为0
dim ctl as control
for each ctl in from1.controls
ctl.text=""
next ctl