⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 这里有很多很实用的VB编程案例,方便大家学习VB.
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   AutoRedraw      =   -1  'True
   BackColor       =   &H8000000D&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   480
   ClientLeft      =   990
   ClientTop       =   570
   ClientWidth     =   480
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   480
   ScaleWidth      =   480
   ShowInTaskbar   =   0   'False
   Begin VB.PictureBox Picture1 
      BackColor       =   &H8000000D&
      BorderStyle     =   0  'None
      DragMode        =   1  'Automatic
      Height          =   492
      Index           =   3
      Left            =   0
      Picture         =   "Form1.frx":030A
      ScaleHeight     =   495
      ScaleWidth      =   495
      TabIndex        =   3
      Top             =   0
      Width           =   492
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H8000000D&
      BorderStyle     =   0  'None
      DragMode        =   1  'Automatic
      Height          =   492
      Index           =   2
      Left            =   0
      Picture         =   "Form1.frx":0614
      ScaleHeight     =   495
      ScaleWidth      =   495
      TabIndex        =   2
      Top             =   0
      Width           =   492
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H8000000D&
      BorderStyle     =   0  'None
      DragMode        =   1  'Automatic
      Height          =   492
      Index           =   1
      Left            =   0
      Picture         =   "Form1.frx":091E
      ScaleHeight     =   495
      ScaleWidth      =   495
      TabIndex        =   1
      Top             =   0
      Width           =   492
   End
   Begin VB.Timer Timer1 
      Left            =   120
      Top             =   120
   End
   Begin VB.PictureBox Picture1 
      BackColor       =   &H8000000D&
      BorderStyle     =   0  'None
      DragMode        =   1  'Automatic
      Height          =   492
      Index           =   0
      Left            =   0
      Picture         =   "Form1.frx":0C28
      ScaleHeight     =   495
      ScaleWidth      =   495
      TabIndex        =   0
      Top             =   0
      Width           =   492
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False


Option Explicit

Dim FSO As FileSystemObject
Dim Unidad As Drive
Dim aUnidades(2) As String
'检测CDROM的变量。
Dim Flag As Boolean

Private Sub Form_Load()
    Dim sDrive As String
    Me.Top = (Screen.Height / 10) + Me.Height
    Me.Left = (Screen.Width - Me.Width) / 2
    Set FSO = New FileSystemObject
    Me.AutoRedraw = True
    Timer1.Enabled = True
    Timer1.Interval = 100

    For Each Unidad In FSO.Drives
        sDrive = Unidad.DriveLetter + ":\"
        If GetDriveType(sDrive) = 5 Then
            Static Cont As Integer
            aUnidades(Cont) = sDrive
            Cont = Cont + 1
        End If
    Next
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim lngReturnValue As Long
    Dim Resp
    If Button = vbRightButton Then
        Resp = MsgBox("中止吗?", vbInformation + vbYesNo, "CDROM")
        If Resp = 6 Then End
    End If
    If Button = vbLeftButton Then
        Call ReleaseCapture
        lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Set Form1 = Nothing
End Sub

Private Sub Picture1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If X <> 0 And Y <> 0 Then
        Picture1(0).Visible = False
        Picture1(1).Visible = False
        Picture1(2).Visible = False
        Picture1(3).Visible = False
    End If
End Sub

Private Sub Timer1_Timer()
    DoEvents
    Dim i As Integer
    Static Cont As Integer
    For i = LBound(aUnidades) To UBound(aUnidades) - 1
        If aUnidades(i) <> "" Then
            Set Unidad = FSO.GetDrive(aUnidades(i))
        End If
  
        Static Cont2 As Integer
        If Not Unidad.IsReady Then
            Cont2 = Cont2 + 1
        End If
    Next i
 
    If Cont2 > 1 Then
        Flag = False
        Cont2 = 0
    Else
        Flag = True
        Cont2 = 0
    End If
 
    If Not Unidad.IsReady And Flag = False Then
        Me.Visible = False
    Else
        Me.Visible = True
        Timer1.Enabled = True
    End If

    Picture1(Cont).Visible = True
    If Cont = 0 Then
        Picture1(0).Visible = True
        Picture1(1).Visible = False
        Picture1(2).Visible = False
        Picture1(3).Visible = False
    ElseIf Cont = 1 Then
        Picture1(1).Visible = True
        Picture1(0).Visible = False
        Picture1(2).Visible = False
        Picture1(3).Visible = False
    ElseIf Cont = 2 Then
        Picture1(2).Visible = True
        Picture1(0).Visible = False
        Picture1(1).Visible = False
        Picture1(3).Visible = False
    ElseIf Cont = 3 Then
        Picture1(3).Visible = True
        Picture1(0).Visible = False
        Picture1(1).Visible = False
        Picture1(2).Visible = False
    End If
 
    Cont = Cont + 1
    If Cont = 3 Then Cont = 0
    DoEvents
End Sub

⌨️ 快捷键说明

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