private sub text1.gotfocus()
on error resume enxt
text1.selstart=instr(text1.text,"*")
end sub
private sub text1_keypress(keycode as integer)
on error resume enxt
if len(text1.text)>text1.selstart then
if mid(text1.text,text1.selstart,1)="*" then
text1.text=left(text1.text,text1.selstart-1) & chr(keycode) & mid(text1.text,text1.selstart+1)
keycode=0
endif
endif
end sub
on error resume enxt
text1.selstart=instr(text1.text,"*")
end sub
private sub text1_keypress(keycode as integer)
on error resume enxt
if len(text1.text)>text1.selstart then
if mid(text1.text,text1.selstart,1)="*" then
text1.text=left(text1.text,text1.selstart-1) & chr(keycode) & mid(text1.text,text1.selstart+1)
keycode=0
endif
endif
end sub
x = InStr(Text1.Text, "*")
if x=0 then
msgbox "*已经完全替换完了!"
endif
End SubPrivate Sub Text1_GotFocus()
x = InStr(Text1.Text, "*")
Text1.SelStart = x - 1
End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
Text1.SelStart = x - 1
Text1.SelLength = 1
End Sub
仓促之间写的程序,希望对您有所帮助!
Text1_GotFocus
End SubPublic Sub Text1_GotFocus()
On Error Resume Next
Text1.Text = "ab*****c"
Text1.SetFocus
Text1.SelStart = InStr(Text1.Text, "*") - 1
End SubPrivate Sub text1_keypress(keycode As Integer)
On Error Resume Next
If Mid(Text1.Text, Text1.SelStart + 1, 1) = "*" Then
Dim str As String
str = Mid(Text1.Text, Text1.SelStart + 2)
Text1.Text = Left(Text1.Text, Text1.SelStart) & Chr(keycode) & str
Text1.SelStart = InStr(Text1.Text, "*") - 1
keycode = 0
End If
End Sub给分!!