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

📄 module.bas

📁 vb精彩编程希望大家有用
💻 BAS
字号:
Attribute VB_Name = "modules"
'存储背景图片的变量
Global BackPicture As String

'设置背景图片的子过程
Sub ShowBackGround(Frm As Form)
    '将Pic定义为StdPicture对象(StdPicture对象是包含各种图元的对象)
    Dim Pic As StdPicture
    '如果选择图片时,按下“取消”按钮(也就是没有选中文件)
    If BackPicture = "" Then Exit Sub
    '先清空窗体上原有图片背景
    Frm.Cls
    '如果出现异常错误,转向错误处理语句
    On Error GoTo ErrorPic
    '将选中的图片文件加载到Pic中
    Set Pic = LoadPicture(BackPicture)
    '下面将图片排满整个窗体
    W = 0
    H1 = Pic.Height / 27
    W1 = Pic.Width / 27
    While W < Frm.ScaleWidth
        H = 0
        While H < Frm.ScaleHeight
            Frm.PaintPicture Pic, W, H
            H = H + H1
        Wend
        W = W + W1
    Wend
    'ShowBorder Frm
    Exit Sub
'如果出现异常错误,则恢复默认的背景图片
ErrorPic:
    If Err.Number = 481 Then
        MsgBox " Picture File Error!"
    End If
    If BackPicture <> App.Path + "\default.JPG" Then
        BackPicture = App.Path + "\default.JPG"
        Set Pic = LoadPicture(BackPicture)
        Resume Next
    End If
End Sub

⌨️ 快捷键说明

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