admin 管理员组

文章数量: 1086019


2024年3月14日发(作者:sedex官网登录)

倒计时VB源代码

复制下面代码到txt文件,将扩展名改成frm即可用VB运行。

VERSION 5.00

Begin Form1

Caption = "倒计时"

ClientHeight = 3030

ClientLeft = 120

ClientTop = 450

ClientWidth = 5430

LinkTopic = "Form1"

ScaleHeight = 3030

ScaleWidth = 5430

StartUpPosition = 3 '窗口缺省

Begin Timer1

Interval = 1000

Left = 4680

Top = 1920

End

Begin dButton Command3

Caption = "复位"

BeginProperty Font

Name = "宋体"

Size = 14.25

Charset = 134

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 615

Left = 3480

TabIndex = 3

Top = 2040

Width = 1455

End

Begin dButton Command2

Caption = "暂停"

BeginProperty Font

Name = "宋体"

Size = 14.25

Charset = 134

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 615

Left = 1800

TabIndex = 2

Top = 2040

Width = 1455

End

Begin dButton Command1

Caption = "计时"

BeginProperty Font

Name = "宋体"

Size = 14.25

Charset = 134

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 615

Left = 120

TabIndex = 0

Top = 2040

Width = 1455

End

Begin Label2

BackStyle = 0 'Transparent

Caption = "程序设计:杜宗飞"

ForeColor = &H00FF8080&

Height = 255

Left = 1800

TabIndex = 4

Top = 2760

Width = 1695

End

Begin Label1

Alignment = 2 'Center

BackStyle = 0 'Transparent

BeginProperty Font

Name = "宋体"

Size = 60

Charset = 134

Weight = 700

Underline = 0 'False

Italic = 0 'False

Strikethrough = 0 'False

EndProperty

Height = 1455

Left = 480

TabIndex = 1

Top = 240

Width = 4335

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

Option Explicit

Private InitWidth As Long ' Form 的原始大小

Private InitHeight As Long

Dim t As Integer

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal

hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long,

ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const HWND_TOPMOST& = -1

Private Const SWP_NOSIZE& = &H1

Private Const SWP_NOMOVE& = &H2

Private Sub Timer1_Timer()

t = t - 1

If t Mod 60 < 10 Then

n = Int(t / 60) & "分" & "0" & t Mod 60 & "秒"

Else

n = Int(t / 60) & "分" & t Mod 60 & "秒"

End If

If t = 0 Then

d = False

lor = RGB(255, 0, 0)

End If

End Sub

Private Sub Command1_Click()

t = 181

d = True

lor = &H8000000F

End Sub

Private Sub Command2_Click()

If d Then

d = False

n = "继续"

Else

d = True

n = "暂停"

End If

End Sub

Private Sub Command3_Click()

d = False

n = "暂停"

n = "0分0秒"

lor = &H8000000F

End Sub

Private Sub Form_Load()

SetWindowPos , HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE

d = False

InitWidth = ScaleWidth

InitHeight = ScaleHeight

Dim Ctl As Control

' 记录每个 Control 的原始位置、大小、字型大小, 放在 Tag 属性中

On Error Resume Next '确保left, top, width, height, Tag属性没有全有的

Control

For Each Ctl In Me '也能正常执行

= & " " & & " " & & " " & &

" "

= & ze & " "

Next Ctl

On Error GoTo 0

End Sub

Private Sub Form_Resize()

Dim D(4) As Double

Dim I As Long

Dim TempPos As Long

Dim StartPos As Long

Dim Ctl As Control

Dim TempVisible As Boolean

Dim ScaleX As Double

Dim ScaleY As Double

ScaleX = ScaleWidth / InitWidth

ScaleY = ScaleHeight / InitHeight

On Error Resume Next

For Each Ctl In Me

TempVisible = e

e = False

StartPos = 1

' 读取 Control 的原始位置、大小、字型大小

For I = 0 To 4

TempPos = InStr(StartPos, , " ", vbTextCompare)

If TempPos > 0 Then

D(I) = Mid(, StartPos, TempPos - StartPos)

StartPos = TempPos + 1

Else

D(I) = 0

End If

' 根据比例设定 Control 的位置、大小、字型大小

D(0) * ScaleX, D(1) * ScaleY, D(2) * ScaleX, D(3) * ScaleY

' = D(2) * ScaleX

' = D(3) * ScaleY

If ScaleX < ScaleY Then

ze = D(4) * ScaleX

Else

ze = D(4) * ScaleY

End If

Next I

e = TempVisible

Next Ctl

On Error GoTo 0

End Sub


本文标签: 位置 字型 文件 代码 属性