关于VB的程序编写
来源:百度知道 编辑:UC知道 时间:2024/07/01 00:09:41
在text1中输入若干字符,并用鼠标选中一些字符后,单击“显示选中信息”按钮,则把选中的第一个字符的顺序号显示在text2中,选中的字符长度显示在text3中,这个程序怎么编写?
Private Sub Command1_Click()'显示选中信息
Text2.Text = Text1.SelStart
Text3.Text = Text1.SelLength
End Sub
'或者
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text2.Text = Text1.SelStart
Text3.Text = Text1.SelLength
End Sub
这样就可以了
Private Sub Command1_Click()
Text2.Text = Text1.SelStart
Text3.Text = Text1.SelLength
End Sub
不对
Dim i
For i = 0 To Len(Text1.Text)
If Mid(Text1.Text, i, i + 1) = Left(Text1.SelText, 1) Then
Text2.Text = i
End If
Next i
Text3.Text = Text1.SelLength
Private Sub Command1_Click()
Dim a As String, b As String
a = Text1.Text
b = b + Text1.SelText
Text2.Text = b
Text3.Text = Len(b)
End Sub