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

📄 form1.frm

📁 将数字转换成一个有效的时间 .
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Convert Number to Time"
   ClientHeight    =   3480
   ClientLeft      =   3780
   ClientTop       =   2355
   ClientWidth     =   3315
   LinkTopic       =   "Form1"
   ScaleHeight     =   3480
   ScaleWidth      =   3315
   Begin VB.TextBox txttime 
      Height          =   375
      Left            =   360
      Locked          =   -1  'True
      TabIndex        =   3
      Top             =   2280
      Width           =   2415
   End
   Begin VB.CommandButton cmdconvert 
      Caption         =   "&Convert"
      Height          =   375
      Left            =   720
      TabIndex        =   2
      Top             =   1440
      Width           =   1695
   End
   Begin VB.TextBox txtText 
      Height          =   375
      Left            =   360
      TabIndex        =   0
      Top             =   720
      Width           =   2415
   End
   Begin VB.Label Label2 
      Caption         =   "The Time"
      Height          =   255
      Left            =   360
      TabIndex        =   4
      Top             =   2040
      Width           =   1335
   End
   Begin VB.Label Label1 
      Caption         =   "Number to convert to Time"
      Height          =   255
      Left            =   360
      TabIndex        =   1
      Top             =   480
      Width           =   2055
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Function CheckTijd(bron$) As Date
    Dim t%
    'checking on digits and seperator
    Const Getal$ = "1234567890.:"
    
    For t% = 1 To Len(bron$)
        If InStr(Getal$, Mid$(bron$, t%, 1)) = 0 Then Exit Function
        If Mid$(bron$, t%, 1) = "." Then bron$ = Left$(bron$, t% - 1) & ":" & Right$(bron$, Len(bron$) - t%)
    Next t%
    
    Select Case Len(bron$)
    Case 0
        Exit Function
    Case 1
        bron$ = "0" & bron$ & ":00"
    Case 2
        bron$ = bron$ & ":00"
    Case 3
        t% = InStr(bron$, ":")
        If t% = 0 Then _
            bron$ = Left$(bron$, 1) & ":" & Right$(bron$, 2)
    Case 4
        t% = InStr(bron$, ":")
        If t% = 0 Then _
            bron$ = Left$(bron$, 2) & ":" & Right$(bron$, 2)
    Case 5
        bron$ = Left$(bron$, 2) & ":" & Right$(bron$, 2)
    End Select
    
    On Error Resume Next
    CheckTijd = TimeValue(bron$)

End Function

Private Sub cmdconvert_Click()
  txttime.Text = CheckTijd(txttext.Text)
End Sub

⌨️ 快捷键说明

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