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

📄 module1.bas

📁 这里有很多很实用的VB编程案例,方便大家学习VB.
💻 BAS
字号:
Attribute VB_Name = "Module1"
'存储背景图片的变量
Global BackPicture As String

Public Sub SetBackGround(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 / 7
        W1 = Pic.Width / 7
        While W < Frm.ScaleWidth
            H = 0
            While H < Frm.ScaleHeight
                Frm.PaintPicture Pic, W, H
                H = H + H1
            Wend
            W = W + W1
        Wend
        Exit Sub

    '如果出现异常错误,则恢复默认的背景图片。
ErrorPic:
    If Err.Number = 481 Then
        MsgBox " Picture File Error!"
    End If
    If BackPicture <> App.Path + "\zmhh.JPG" Then
        BackPicture = App.Path + "\zmhh.JPG"
        Set Pic = LoadPicture(BackPicture)
        Resume Next
    End If
End Sub

⌨️ 快捷键说明

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