frmfiledel.frm

来自「电梯检测系统是对电梯性能进行检测的系统。是一个用来学习的程序。」· FRM 代码 · 共 195 行

FRM
195
字号
VERSION 5.00
Begin VB.Form FrmFileDel 
   BorderStyle     =   5  'Sizable ToolWindow
   Caption         =   "Delete file"
   ClientHeight    =   2805
   ClientLeft      =   60
   ClientTop       =   285
   ClientWidth     =   4860
   BeginProperty Font 
      Name            =   "Arial"
      Size            =   12
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2805
   ScaleWidth      =   4860
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton CancelCmd 
      Caption         =   "Cancel"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   10.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2520
      TabIndex        =   5
      Top             =   2040
      Width           =   2055
   End
   Begin VB.CommandButton EnterCmd 
      Caption         =   "Delete"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   10.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2520
      TabIndex        =   4
      Top             =   1440
      Width           =   2055
   End
   Begin VB.TextBox FileName 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2520
      TabIndex        =   2
      Top             =   480
      Width           =   2175
   End
   Begin VB.FileListBox FileList 
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   1890
      Hidden          =   -1  'True
      Left            =   120
      Pattern         =   "*.ini"
      TabIndex        =   0
      Top             =   480
      Width           =   2055
   End
   Begin VB.Label Label2 
      Caption         =   "File name:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   10.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2520
      TabIndex        =   3
      Top             =   120
      Width           =   2295
   End
   Begin VB.Label Label1 
      Caption         =   "Select file:"
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   10.5
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   240
      TabIndex        =   1
      Top             =   120
      Width           =   1935
   End
End
Attribute VB_Name = "FrmFileDel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Function BolGetFromINI(SectionHeader$, VarName$, FileName$) As Boolean
   On Error GoTo err
   Dim RetString As String, TempStr As String
   RetString = String(255, Chr(0))
  'Get Requested Information
   TempStr = left(RetString, GetPrivateProfileString(SectionHeader$, ByVal VarName$, "", RetString, Len(RetString), FileName$))
   If TempStr <> "" Then
     BolGetFromINI = True
   Else
     BolGetFromINI = False
   End If
   Exit Function
err:
   BolGetFromINI = False
End Function



Private Sub CancelCmd_Click()
  Unload Me
End Sub

Private Sub EnterCmd_Click()
  Dim fso
  Dim i As Integer, TempI As Integer
  Dim TempStr
  err.Clear
  On Error Resume Next
  Set fso = CreateObject("Scripting.FileSystemObject")
  If Not fso.fileexists(App.Path & "\FuncTest\" & FileName.Text) Then
    MsgBox "File is not exist.", , "Error"
    Exit Sub
  End If
  If MsgBox("Delelte this file?This may lose some data,confirm do not need this file.", vbOKCancel, "Warning") = vbOK Then
    TempI = GetFromINI("count", "count", App.Path & "\functest\" & FileName.Text)
    For i = 1 To TempI
      If BolGetFromINI("test trip", i & "msg", App.Path & "\functest\" & FileName.Text) Then
        TempStr = GetFromINI("test trip", i & "msg", App.Path & "\functest\" & FileName.Text)
        Kill TempStr
        If err.Number = 53 Then
          MsgBox "Not found " & TempStr
        End If
      End If
    Next
    fso.deletefile App.Path & "\FuncTest\" & FileName.Text
    FileList.Refresh
    FileList_Click
  End If
  
End Sub

Private Sub FileList_Click()
  FileName.Text = Trim$(FileList.FileName)
End Sub

Private Sub Form_Load()
  FileList.Path = App.Path & "\FuncTest"
End Sub


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?