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

📄 中英互译.frm

📁 Visual Basic课程举例1 有很好的例题
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "简单的翻译程序"
   ClientHeight    =   2940
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6570
   LinkTopic       =   "Form1"
   ScaleHeight     =   2940
   ScaleWidth      =   6570
   StartUpPosition =   3  '窗口缺省
   Begin VB.OptionButton EToC 
      Caption         =   "英译中"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   555
      Left            =   2160
      TabIndex        =   6
      Top             =   2160
      Width           =   1515
   End
   Begin VB.OptionButton CToE 
      Caption         =   "中译英"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      TabIndex        =   5
      Top             =   2160
      Value           =   -1  'True
      Width           =   1515
   End
   Begin VB.TextBox Text2 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   21.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1200
      TabIndex        =   2
      Top             =   1260
      Width           =   5295
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   21.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   1200
      TabIndex        =   1
      Top             =   420
      Width           =   5355
   End
   Begin VB.CommandButton Command1 
      Caption         =   "开始翻译"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   18
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   555
      Left            =   4380
      TabIndex        =   0
      Top             =   2160
      Width           =   1995
   End
   Begin VB.Label Label2 
      Caption         =   "译文"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   21.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   120
      TabIndex        =   4
      Top             =   1380
      Width           =   915
   End
   Begin VB.Label Label1 
      Caption         =   "原文"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   21.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   60
      TabIndex        =   3
      Top             =   420
      Width           =   1035
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim A$, B$, D$(4, 2)

D$(1, 1) = "I": D$(1, 2) = "我"
D$(2, 1) = "U": D$(2, 2) = "你"
D$(3, 1) = "VB": D$(3, 2) = "Visual BASIC"
D$(4, 1) = "unknow": D$(4, 2) = "不知道"

A$ = Text1.Text '取出欲判断字符串
'例:如果选择中译英,则“我服了你了!”能翻译成 “I服了U了!”
'
For I = 1 To 4
    If CToE Then
        A$ = Replace(A$, D$(I, 2), D$(I, 1), , , vbTextCompare)
    Else
        A$ = Replace(A$, D$(I, 1), D$(I, 2), , , vbTextCompare)
    End If
Next I

Text2.Text = A$     '输出译后的文字

End Sub

⌨️ 快捷键说明

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