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

📄 form1.frm

📁 一个将质量(重量)进行转换的小程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H00C0E0FF&
   Caption         =   "公式换算器V1.0"
   ClientHeight    =   5145
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8055
   Icon            =   "Form1.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5145
   ScaleWidth      =   8055
   StartUpPosition =   2  '屏幕中心
   Begin VB.Frame Frame1 
      BackColor       =   &H00C0E0FF&
      Caption         =   "转换工具"
      Height          =   1335
      Left            =   120
      TabIndex        =   1
      Top             =   3720
      Width           =   7815
      Begin VB.TextBox Text3 
         Appearance      =   0  'Flat
         BackColor       =   &H00C0E0FF&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3960
         TabIndex        =   9
         Top             =   480
         Width           =   3735
      End
      Begin VB.ComboBox Combo1 
         BackColor       =   &H00FFC0C0&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         ItemData        =   "Form1.frx":030A
         Left            =   1680
         List            =   "Form1.frx":031D
         Style           =   2  'Dropdown List
         TabIndex        =   7
         Top             =   480
         Width           =   975
      End
      Begin VB.ComboBox Combo2 
         BackColor       =   &H00FFC0C0&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   360
         ItemData        =   "Form1.frx":0337
         Left            =   2760
         List            =   "Form1.frx":034A
         Style           =   2  'Dropdown List
         TabIndex        =   6
         Top             =   480
         Width           =   855
      End
      Begin VB.TextBox Text2 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFC0C0&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         MaxLength       =   20
         TabIndex        =   2
         Text            =   "0"
         Top             =   480
         Width           =   1455
      End
      Begin VB.Label Label4 
         BackColor       =   &H00C0E0FF&
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00000000&
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   960
         Width           =   7575
      End
      Begin VB.Label Label5 
         BackColor       =   &H00C0E0FF&
         Caption         =   "="
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3720
         TabIndex        =   8
         Top             =   480
         Width           =   375
      End
      Begin VB.Label Label3 
         BackColor       =   &H00C0E0FF&
         Caption         =   "转换后单位"
         Height          =   375
         Left            =   2760
         TabIndex        =   5
         Top             =   240
         Width           =   1455
      End
      Begin VB.Label Label2 
         BackColor       =   &H00C0E0FF&
         Caption         =   "原单位"
         Height          =   375
         Left            =   1800
         TabIndex        =   4
         Top             =   240
         Width           =   855
      End
      Begin VB.Label Label1 
         BackColor       =   &H00C0E0FF&
         Caption         =   "需要转换的数值"
         Height          =   375
         Left            =   120
         TabIndex        =   3
         Top             =   240
         Width           =   1455
      End
   End
   Begin VB.TextBox Text1 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Height          =   3495
      Left            =   120
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      TabIndex        =   0
      Text            =   "Form1.frx":0364
      Top             =   120
      Width           =   7815
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False






Private Sub Combo1_Click()
begin_js
End Sub

Private Sub Combo2_Click()
begin_js
End Sub

Private Sub begin_js()
If Text2.Text = "" Or Val(Text2.Text) = 0 Then
  Label4.Caption = "请输入需要转换的数值!"
  Exit Sub
End If

If Not IsNumeric(Text2.Text) Then
  Label4.Caption = "请检查你输入的数值是否正确!"
  Exit Sub
End If

temp_a = 0 '原单位
temp_b = 0 '转换后单位

If Combo1.Text = "克" Then
   temp_a = 1
ElseIf Combo1.Text = "钱" Then
   temp_a = 0.2
ElseIf Combo1.Text = "两" Then
   temp_a = 0.02
ElseIf Combo1.Text = "斤" Then
   temp_a = 0.002
ElseIf Combo1.Text = "公斤" Then
   temp_a = 0.001
End If

If Combo2.Text = "克" Then
   temp_b = 1
ElseIf Combo2.Text = "钱" Then
   temp_b = 0.2
ElseIf Combo2.Text = "两" Then
   temp_b = 0.02
ElseIf Combo2.Text = "斤" Then
   temp_b = 0.002
ElseIf Combo2.Text = "公斤" Then
   temp_b = 0.001
End If

If temp_a = temp_b Then
   Text3.Text = Text2.Text & Combo2.Text
   Exit Sub
End If

If temp_a < temp_b Then
Text3.Text = Text2.Text / temp_a * temp_b

Text3.Text = Format(Text3.Text, "###,###,###,###,###.##")
        If Right(Text3.Text, 1) = "." Then
              Text3.Text = Left(Text3.Text, Len(Text3.Text) - 1) & Combo2.Text
        Else
              Text3.Text = Text3.Text & Combo2.Text
        End If





Else
Text3.Text = Text2.Text / temp_a * temp_b
Text3.Text = Format(Text3.Text, "###,###,###,###,###.##")

        If Right(Text3.Text, 1) = "." Then
              Text3.Text = Left(Text3.Text, Len(Text3.Text) - 1) & Combo2.Text
        Else
              Text3.Text = Text3.Text & Combo2.Text
        End If






End If




End Sub




Private Sub Form_Load()
Combo1.Text = "克"
Combo2.Text = "克"
End Sub

Private Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
begin_js
End Sub

⌨️ 快捷键说明

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