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

📄 frmbuttondraw.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmButtonDraw 
   Caption         =   "Fig. 6.9: Drawing an image on a button"
   ClientHeight    =   2100
   ClientLeft      =   2280
   ClientTop       =   2250
   ClientWidth     =   5340
   LinkTopic       =   "Form1"
   ScaleHeight     =   2100
   ScaleWidth      =   5340
   Begin VB.TextBox txtInput 
      Height          =   375
      Left            =   4665
      MaxLength       =   1
      TabIndex        =   0
      Top             =   195
      Width           =   450
   End
   Begin VB.CommandButton cmdButton 
      BackColor       =   &H0080FFFF&
      Caption         =   "Click Here"
      Height          =   1170
      Left            =   2130
      MaskColor       =   &H00FFFFFF&
      Style           =   1  'Graphical
      TabIndex        =   1
      Top             =   765
      Width           =   1350
   End
   Begin VB.Label lblPrompt 
      Caption         =   "Enter a number in the range 1 to 6 and then press the button:"
      Height          =   270
      Left            =   255
      TabIndex        =   2
      Top             =   225
      Width           =   4395
   End
End
Attribute VB_Name = "frmButtonDraw"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 6.9 code listing
' Using a programmer-defined function
Option Explicit           ' General declaration

Private Sub cmdButton_Click()
   Dim value As Integer, name As String
   
   value = txtInput.Text
   
   If value >= 1 And value <= 6 Then
      name = GetImage(value)   ' Invoke function getImage
      cmdButton.Picture = LoadPicture(name)
   Else
      txtInput.Text = ""     ' Clear txtInput
   End If
   
End Sub

' GetImage is a programmer defined function
Private Function GetImage(n As Integer) As String
   GetImage = "d:\images\common\die" & n & ".gif"
End Function

⌨️ 快捷键说明

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