以下是我用VB写的一段程序,与你的要求类似,你考虑一下吧! 本程序有一个文本框控件! 可以对字符"."前的字符进行敏感 而你可以重新定义字符".",将其改为"!"等等其它的字符!Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As Long End Type Private startsave As Boolean Private str As String Private newline As Boolean Private oldposi As LongPrivate Sub Form_Load() Dim ret As Long Dim point As POINTAPI Form1.Text1.Text = "" startsave = False str = "" SendKeys Space(2) ret = GetCaretPos(point) List1.Visible = False End SubPrivate Sub List1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Or KeyAscii = Asc(Space(1)) Then List1.Visible = False SendKeys List1.List(List1.ListIndex) ElseIf KeyAscii = vbKeyBack Or KeyAscii = vbKeyEscape Then List1.Visible = False Text1.SetFocus End If End SubPrivate Sub Text1_Change() Dim midchar As StringIf Text1.SelStart >= 1 Then midchar = Mid(Text1.Text, Text1.SelStart, 1) End If If midchar = Space(1) Then startsave = True str = "" End IfIf Text1.SelStart > 1 ThenIf Mid(Text1.Text, Text1.SelStart - 1, 1) = Chr(10) Then startsave = True str = "" End IfEnd IfIf midchar = "." Then judgeit (str) End IfIf startsave And midchar <> Space(1) Then
If oldposi < Text1.SelStart Then str = str & midchar Else If Len(str) > 1 Then str = Left(str, Len(str) - 1) End If End If End Ifoldposi = Text1.SelStart End SubFunction judgeit(ByVal strtemp As String) Dim point As POINTAPI Dim ret As Long Select Case strtempCase "zf": 对zf敏感 ret = GetCaretPos(point) List1.Visible = True For i = 0 To 10 List1.AddItem i Next List1.Left = Text1.Left + point.x + 5 List1.Top = Text1.Top + point.y + 3 List1.SetFocus List1.ListIndex = 0Case "bss": 对bss敏感 ret = GetCaretPos(point) List1.Visible = True For i = 10 To 20 List1.AddItem i Next List1.Left = Text1.Left + point.x + 5 List1.Top = Text1.Top + point.y + 3 List1.SetFocus List1.ListIndex = 0 Case Else: 在这里你可以定义别的单词敏感 End Select End Function
你是要实现大小写敏感的vb还是要写一个程序书写器?后者有大把控件例如CodeMax和源程序可以使用。
本程序有一个文本框控件!
可以对字符"."前的字符进行敏感
而你可以重新定义字符".",将其改为"!"等等其它的字符!Private Declare Function GetCaretPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private startsave As Boolean
Private str As String
Private newline As Boolean
Private oldposi As LongPrivate Sub Form_Load()
Dim ret As Long
Dim point As POINTAPI
Form1.Text1.Text = ""
startsave = False
str = ""
SendKeys Space(2)
ret = GetCaretPos(point)
List1.Visible = False
End SubPrivate Sub List1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Or KeyAscii = Asc(Space(1)) Then
List1.Visible = False
SendKeys List1.List(List1.ListIndex)
ElseIf KeyAscii = vbKeyBack Or KeyAscii = vbKeyEscape Then
List1.Visible = False
Text1.SetFocus
End If
End SubPrivate Sub Text1_Change()
Dim midchar As StringIf Text1.SelStart >= 1 Then
midchar = Mid(Text1.Text, Text1.SelStart, 1)
End If
If midchar = Space(1) Then
startsave = True
str = ""
End IfIf Text1.SelStart > 1 ThenIf Mid(Text1.Text, Text1.SelStart - 1, 1) = Chr(10) Then
startsave = True
str = ""
End IfEnd IfIf midchar = "." Then
judgeit (str)
End IfIf startsave And midchar <> Space(1) Then
If oldposi < Text1.SelStart Then
str = str & midchar
Else
If Len(str) > 1 Then
str = Left(str, Len(str) - 1)
End If
End If
End Ifoldposi = Text1.SelStart
End SubFunction judgeit(ByVal strtemp As String)
Dim point As POINTAPI
Dim ret As Long
Select Case strtempCase "zf": 对zf敏感
ret = GetCaretPos(point)
List1.Visible = True
For i = 0 To 10
List1.AddItem i
Next
List1.Left = Text1.Left + point.x + 5
List1.Top = Text1.Top + point.y + 3
List1.SetFocus
List1.ListIndex = 0Case "bss": 对bss敏感
ret = GetCaretPos(point)
List1.Visible = True
For i = 10 To 20
List1.AddItem i
Next
List1.Left = Text1.Left + point.x + 5
List1.Top = Text1.Top + point.y + 3
List1.SetFocus
List1.ListIndex = 0
Case Else: 在这里你可以定义别的单词敏感
End Select
End Function