📄 frmfave.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmFave
Caption = "网址收藏夹"
ClientHeight = 5400
ClientLeft = 60
ClientTop = 345
ClientWidth = 6675
LinkTopic = "Form1"
ScaleHeight = 5400
ScaleWidth = 6675
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdReturn
Caption = "返回"
Height = 330
Left = 4875
TabIndex = 12
Top = 5010
Width = 1260
End
Begin VB.Frame Frame2
Height = 1455
Left = 2100
TabIndex = 5
Top = 3465
Width = 4455
Begin VB.CommandButton cmdEditAdd
Caption = "编辑地址"
Enabled = 0 'False
Height = 345
Left = 3360
TabIndex = 13
Top = 150
Width = 930
End
Begin VB.CommandButton cmdAdd
Caption = "加入地址"
Height = 360
Left = 975
TabIndex = 9
Top = 165
Width = 1065
End
Begin VB.TextBox txtAdd
Appearance = 0 'Flat
Height = 345
Left = 1140
TabIndex = 8
Text = "txtAdd"
Top = 1020
Width = 3135
End
Begin VB.TextBox txtSubject
Appearance = 0 'Flat
Height = 315
Left = 1155
TabIndex = 7
Text = "txtSubject"
Top = 645
Width = 3120
End
Begin VB.CommandButton cmdDelAdd
Caption = "删除地址"
Height = 345
Left = 2235
TabIndex = 6
Top = 165
Width = 975
End
Begin VB.Label Label2
Caption = "地址:"
Height = 360
Left = 315
TabIndex = 11
Top = 1005
Width = 675
End
Begin VB.Label Label1
Caption = "主题:"
Height = 285
Left = 330
TabIndex = 10
Top = 645
Width = 735
End
End
Begin VB.Frame Frame1
Caption = "收藏夹"
Height = 1455
Left = 75
TabIndex = 2
Top = 3465
Width = 1905
Begin VB.CommandButton cmdAddFold
Caption = "新建收藏夹"
Height = 330
Left = 330
TabIndex = 4
Top = 390
Width = 1215
End
Begin VB.CommandButton cmdRemoveFold
Caption = "删除收藏夹"
Height = 345
Left = 330
TabIndex = 3
Top = 825
Width = 1200
End
End
Begin MSComctlLib.ListView lsvAdd
Height = 3225
Left = 2190
TabIndex = 1
Top = 135
Width = 4365
_ExtentX = 7699
_ExtentY = 5689
LabelWrap = -1 'True
HideSelection = -1 'True
_Version = 393217
Icons = "ImgList2"
SmallIcons = "ImgList2"
ColHdrIcons = "ImgList2"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 0
NumItems = 0
End
Begin MSComctlLib.TreeView TreeView1
Height = 3270
Left = 15
TabIndex = 0
Top = 120
Width = 1980
_ExtentX = 3493
_ExtentY = 5768
_Version = 393217
HideSelection = 0 'False
Style = 7
ImageList = "ImgList1"
BorderStyle = 1
Appearance = 0
End
Begin MSComctlLib.ImageList ImgList1
Left = 6075
Top = 3030
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 13
ImageHeight = 13
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmFave.frx":0000
Key = "closed"
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "frmFave.frx":00FC
Key = "open"
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmFave"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim nodroot As Node
Dim faveDB As Database
Dim oldUser As String
Dim oldSubject As String
Dim selItemX As Integer
Private Sub cmdAdd_Click()
'添加网址到收藏夹中,在ListView中显示相应的内容
Dim selItem As Integer
selItem = TreeView1.SelectedItem.Index
If selItem <> 1 Then
Dim itmX As ListItem
Dim subject As String
subject = txtSubject.Text
Set itmX = lsvAdd.ListItems.Add(, , subject)
itmX.SubItems(1) = txtAdd.Text
selItem = TreeView1.SelectedItem.Index
Dim strUser As String
strUser = TreeView1.Nodes(selItem).Text
'从TreeView中取得要添加网址的收藏夹
Dim tempRec
'把网址添加到数据库的表"faveFlod"中
Set tempRec = faveDB.OpenRecordset("faveFold", dbOpenDynaset)
With tempRec
.AddNew
!User = strUser
!subject = txtSubject.Text
!location = txtAdd.Text
.Update
End With
tempRec.Close
End If
End Sub
Private Sub cmdAddFold_Click()
'新建网址收藏夹
Dim Namecorrect As Boolean
Namecorrect = True
Do While Namecorrect
Dim foldname As String
foldname = InputBox("请输入收藏夹的名称。")
Dim flag
'用函数FoldsExsit()判断收藏夹的名称是否已经被利用,如果已经被利用,
'则要求采用另外的名称
flag = FoldIsExsit(foldname)
If flag = -1 Then
If MsgBox("文件夹已经存在,请重新输入名字", vbOKCancel) = vbOK Then
Namecorrect = True
Else
Exit Sub
End If
Else
Namecorrect = False
End If
Loop
'把新建的收藏夹名字添加到数据库的表"user"中
Set tempRec = faveDB.OpenRecordset("user", dbOpenDynaset)
With tempRec
.AddNew
!User = foldname
.Update
End With
tempRec.Close
Dim nodX As Node
'新建收藏夹后,在TreeView中显示
Set nodX = TreeView1.Nodes.Add(nodroot, tvwChild, foldname, foldname)
nodX.Image = "closed"
nodX.EnsureVisible
End Sub
Private Sub cmdDelAdd_Click()
'删除从ListView中选择的网址
Dim i
Dim strSubject As String
For i = 1 To lsvAdd.ListItems.Count
If lsvAdd.ListItems(i).Selected Then
strSubject = lsvAdd.ListItems(i).Text
lsvAdd.ListItems.Remove i
Exit For
End If
Next i
'在ListView中删除后,在收藏网址的数据库中删除相应的记录
If strSubject <> "" Then
Dim tempRec
Dim strUser As String
Dim intTemp As Integer
intTemp = TreeView1.SelectedItem.Index
strUser = TreeView1.Nodes(intTemp).Text
Set tempRec = faveDB.OpenRecordset("faveFold", dbOpenDynaset)
tempRec.MoveFirst
Do Until tempRec.EOF
If tempRec!subject = strSubject And tempRec!User = strUser Then
With tempRec
.Delete
End With
End If
tempRec.MoveNext
Loop
tempRec.Close
End If
End Sub
Private Sub cmdEditAdd_Click()
'修改收藏的网址,更新数据库中相应的记录以及ListView中的显示
Dim tempRec
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -