怎样在vb中实现语法敏感,那里有相关的资源?

ebombsuhocom 2000-06-27 04:24:00
请各位高手指点!谢谢!
...全文
126 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluewater 2000-07-06
  • 打赏
  • 举报
回复
以下是我用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 Long

Private 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 Sub

Private 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 Sub

Private Sub Text1_Change()
Dim midchar As String

If Text1.SelStart >= 1 Then
midchar = Mid(Text1.Text, Text1.SelStart, 1)
End If
If midchar = Space(1) Then
startsave = True
str = ""
End If

If Text1.SelStart > 1 Then

If Mid(Text1.Text, Text1.SelStart - 1, 1) = Chr(10) Then
startsave = True
str = ""
End If

End If

If midchar = "." Then
judgeit (str)
End If



If 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 If

oldposi = Text1.SelStart
End Sub

Function judgeit(ByVal strtemp As String)
Dim point As POINTAPI
Dim ret As Long
Select Case strtemp

Case "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 = 0

Case "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
Un1 2000-06-28
  • 打赏
  • 举报
回复
“语法敏感”??
你是要实现大小写敏感的vb还是要写一个程序书写器?后者有大把控件例如CodeMax和源程序可以使用。
ebombsuhocom 2000-06-28
  • 打赏
  • 举报
回复
就象vb的代码窗口中那样
Limu 2000-06-27
  • 打赏
  • 举报
回复
I don't know what you want,please describe the detail.

1,066

社区成员

发帖
与我相关
我的任务
社区描述
VB 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧