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

📄 frmmain.frm

📁 用户输入0-127之间的数,输出其对应的ascii码的符号
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmMain 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "求Asc码"
   ClientHeight    =   2085
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   2685
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2085
   ScaleWidth      =   2685
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton cmdExit 
      Caption         =   "退出"
      Height          =   390
      Left            =   1875
      TabIndex        =   6
      Top             =   1500
      Width           =   690
   End
   Begin VB.CommandButton cmdClear 
      Caption         =   "清除"
      Height          =   390
      Left            =   975
      TabIndex        =   5
      Top             =   1500
      Width           =   690
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   1050
      TabIndex        =   2
      Top             =   900
      Width           =   1365
   End
   Begin VB.CommandButton cmdOk 
      Caption         =   "确定"
      Height          =   390
      Left            =   75
      TabIndex        =   1
      Top             =   1500
      Width           =   690
   End
   Begin VB.TextBox Text1 
      Height          =   390
      Left            =   1050
      MaxLength       =   2000
      TabIndex        =   0
      Top             =   225
      Width           =   1440
   End
   Begin VB.Label Label2 
      Caption         =   "字符"
      Height          =   390
      Left            =   375
      TabIndex        =   4
      Top             =   1050
      Width           =   765
   End
   Begin VB.Label Label1 
      Caption         =   "请输入数字"
      Height          =   615
      Left            =   75
      TabIndex        =   3
      Top             =   300
      Width           =   1065
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim vbResult As VbMsgBoxResult
Dim i As Integer
Dim str As String
Dim flag As Boolean
Private Sub cmdClear_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text2.Enabled = False
    flag = False
    Text1.SetFocus
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdOk_Click()
    If flag = True Then
        flag = False
    End If
    If Text1.Text = "" Then
        vbResult = MsgBox("不能为空", vbOKOnly, "提示")
        If vbResult = vbOK Then
            Call cmdClear_Click
        End If
    Else
        For i = 1 To Len(Text1.Text)
            str = Mid(Text1.Text, i, 1)
            If Asc(str) > 57 Or Asc(str) < 48 Then
                vbResult = MsgBox("请输入数字", vbOKOnly, "错误提示")
                If vbResult = vbOK Then
                    Call cmdClear_Click
                    flag = True
                    Exit For
                End If
            End If
        Next i
        If flag = False Then
            If CDbl(Text1.Text) > 127 Or CDbl(Text1.Text) < 0 Then
                MsgBox "请输入0--127之间的数!", vbOKOnly, "错误提示"
                Call cmdClear_Click
            Else
                Text2.Enabled = True
                Text2.Text = Chr(CInt(Text1.Text))
            End If
        End If
    End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        Call cmdOk_Click
    End If
End Sub

Private Sub Form_Load()
    Text2.Enabled = False
    flag = False
End Sub

⌨️ 快捷键说明

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