关于VB的查找与替换功能具体细节分析
PrivateSubCommand1_Click()DimzyAsString,StrThAsString,IAsInteger,JAsInteger,KAsIntege...
Private Sub Command1_Click()
Dim zy As String, StrTh As String, I As Integer, J As Integer, K As Integer
zy = InputBox("你要查找什么?", "查找", "")
zj = InputBox("你要将查找到的字符替换成什么?", "替换", "")
On Error Resume Next
I = 0
Do
DoEvents
Text1.SetFocus
Text1.SelStart = InStr(IntKs + 1, Text1, zy) - 1
If Err = 380 Then
MsgBox "查找完毕!", vbOKOnly, "查找完毕"
Exit Sub
End If
IntKs = Text1.SelStart + Len(zy)
Text1.SelLength = Len(zy)
I = I + 1
Label1.Caption = "已经找到" & I & "处"
K = MsgBox("找到第" & I & "处" & zy & ",是否替换?", vbYesNo, "找到第" & I & "处"" & zy & """)
If K = 6 Then
Clipboard.Clear
Clipboard.SetText zj
Text1.SelText = Clipboard.GetText
J = J + 1
Label2.Caption = "您替换了" & J & "次!"
End If
Loop
End Sub
Private Sub Command2_Click()
End
End Sub
期中,为什么Err = 380,K=6? 展开
Dim zy As String, StrTh As String, I As Integer, J As Integer, K As Integer
zy = InputBox("你要查找什么?", "查找", "")
zj = InputBox("你要将查找到的字符替换成什么?", "替换", "")
On Error Resume Next
I = 0
Do
DoEvents
Text1.SetFocus
Text1.SelStart = InStr(IntKs + 1, Text1, zy) - 1
If Err = 380 Then
MsgBox "查找完毕!", vbOKOnly, "查找完毕"
Exit Sub
End If
IntKs = Text1.SelStart + Len(zy)
Text1.SelLength = Len(zy)
I = I + 1
Label1.Caption = "已经找到" & I & "处"
K = MsgBox("找到第" & I & "处" & zy & ",是否替换?", vbYesNo, "找到第" & I & "处"" & zy & """)
If K = 6 Then
Clipboard.Clear
Clipboard.SetText zj
Text1.SelText = Clipboard.GetText
J = J + 1
Label2.Caption = "您替换了" & J & "次!"
End If
Loop
End Sub
Private Sub Command2_Click()
End
End Sub
期中,为什么Err = 380,K=6? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询