📄 frmsetting.frm
字号:
VERSION 5.00
Begin VB.Form frmSetting
Caption = "用户自定义词汇"
ClientHeight = 3525
ClientLeft = 60
ClientTop = 345
ClientWidth = 5415
LinkTopic = "Form2"
ScaleHeight = 3525
ScaleWidth = 5415
StartUpPosition = 3 '窗口缺省
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 300
Left = 240
TabIndex = 5
Top = 2835
Width = 255
End
Begin VB.CommandButton cmdClear
Caption = "全部删除"
Height = 375
Left = 600
TabIndex = 4
Top = 2160
Width = 1095
End
Begin VB.CommandButton cmdDelete
Caption = "删除所选"
Height = 375
Left = 600
TabIndex = 3
Top = 1440
Width = 1095
End
Begin VB.CommandButton cmdAdd
Caption = "加入新词"
Height = 375
Left = 600
TabIndex = 2
Top = 720
Width = 1095
End
Begin VB.TextBox Text1
Height = 375
Left = 120
TabIndex = 1
Top = 120
Width = 1935
End
Begin VB.ListBox List1
Height = 3120
Left = 2280
MultiSelect = 2 'Extended
TabIndex = 0
Top = 120
Width = 3015
End
Begin VB.Label Label1
Caption = "仅显示定义词汇"
Height = 255
Left = 600
TabIndex = 6
Top = 2880
Width = 1575
End
End
Attribute VB_Name = "frmSetting"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim fso As New FileSystemObject
Dim dict As Scripting.Dictionary
Dim ts As TextStream
Dim index&
Private Sub Check1_Click()
If Check1.Value = 1 Then
frmMain.Chk = True
Else
frmMain.Chk = False
End If
End Sub
Private Sub cmdAdd_Click()
If Not dict.Exists(Text1.Text) Then
dict.Add Text1.Text, ""
List1.AddItem Text1.Text
End If
End Sub
Private Sub cmdDelete_Click()
For index = List1.ListCount - 1 To 0 Step -1 '只有通过递减才不会因为Count自动递减而出错
If List1.Selected(index) Then
dict.Remove (List1.List(index))
List1.RemoveItem index
End If
Next index
End Sub
Private Sub cmdClear_Click()
List1.Clear
dict.RemoveAll
End Sub
Private Sub Form_Load()
Dim A, i&
Set dict = frmMain.UserList
A = dict.Keys
List1.Clear
For i = 0 To UBound(A)
List1.AddItem A(i)
Next i
Set ts = fso.OpenTextFile(App.Path & "\UserList.Txt", ForReading, True)
ts.Close
If frmMain.Chk Then Check1.Value = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Kill App.Path & "\Userlist.Txt"
Set ts = fso.OpenTextFile(App.Path & "\UserList.Txt", ForWriting, True)
For index = 0 To List1.ListCount - 1
ts.WriteLine List1.List(index)
Next index
ts.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -