首页 技术 正文
技术 2022年11月8日
0 收藏 676 点赞 1,624 浏览 1767 个字

Private Sub mnuDel_Click()
‘删除节点
Dim sKey As String
‘Dim sFile As String
Dim oFS As FileSystemObject
Dim sPathFile As String
Dim sIndex As String
Dim sFlag As String
Set oFS = New FileSystemObject
On Error Resume Next
If MsgBox(“确定要删除此类别[” & TreeView1.SelectedItem.Text & “]”, vbYesNo, “静态信息”) = vbYes Then
    sKey = TreeView1.SelectedItem.Key
    sIndex = TreeView1.SelectedItem.Index
‘    sFile = sContentPath & sKey & “*” & “.htm”
‘    sFlag = Check(sIndex)
    sFlag = Len(sKey) – 1
    If RemoveInfo(sKey) Then
        TreeView1.Nodes.Remove TreeView1.SelectedItem.Index
        sPathFile = Dir(sContentPath)
        While (sPathFile <> “”)
            If Mid(sPathFile, 2, sFlag) = Right(sKey, Len(sKey) – 1) Then
‘                oFS.DeleteFile sPathFile, True
                Kill sContentPath & sPathFile
            End If
            sPathFile = Dir
        Wend
        If TreeView1.SelectedItem.Children = 0 Then
           TreeView1.SelectedItem.Image = “closed”
        End If
    End If
End If
End Sub

 补充函数Dir用法,Dir(Path)遍历指定目录下的所有文件,第一次返回第一个文件,如果不想重复遍历,下一次调用时不要加参数。

函数Kill用法,Kill(Path&file)删除绝对路径下的文件,不可以缺少目录(或者只写文件名)。

While….Wend循环,类似于C语言的While循环。

If嵌套调用,If…Then…Elseif..Then….EndIf。

Private Function RemoveInfo(sSearch As String) As Boolean
Dim sSQL As String
Dim objDataAccess As clsDataAccess
RemoveInfo = False
On Error GoTo errHandle
‘    sSQL = “Delete From BCCB_Info Where Id=” & Right(sSearch, Len(sSearch) – 1)
    sSQL = “Delete From BCCB_Info Where Id like ‘” & Right(sSearch, Len(sSearch) – 1) & “%'”
    Set objDataAccess = New clsDataAccess
    If objDataAccess.ExecSQL(sSQL) Then RemoveInfo = True
   
    Set objDataAccess = Nothing
Exit Function
errHandle:
    RemoveInfo = False
    Call WriteLog(DEBUG_LEVEL, “frmBCCBInfo.RemoveInfo Error” & err.Description)
    Set objDataAccess = Nothing
End Function

补充语法:

操作数据库过程:

声明一个连接,建立或者实例化一个连接,准备好SQL数据库语句,执行语句,释放连接(适用于Access)。

声明一个连接,建立或者实例化一个连接,声明一个数据集,建立或者实例化一个数据集,准备SQL数据库语句,执行数据库语句,释放数据集,释放连接(适用于ADO.RecordSet)。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,965
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,486
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,331
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,114
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,747
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,781