📄 中英文字符统计.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "中英文字数统计"
ClientHeight = 5520
ClientLeft = 60
ClientTop = 345
ClientWidth = 6480
LinkTopic = "Form1"
ScaleHeight = 5520
ScaleWidth = 6480
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "退出"
Height = 315
Left = 5160
TabIndex = 7
Top = 4800
Width = 915
End
Begin VB.CommandButton Command2
Caption = "清空"
Height = 315
Left = 3960
TabIndex = 6
Top = 4800
Width = 915
End
Begin VB.CommandButton Command1
Caption = "统计"
Height = 315
Left = 2760
TabIndex = 5
Top = 4800
Width = 915
End
Begin VB.TextBox Text1
Height = 4335
Left = 53
MultiLine = -1 'True
OLEDropMode = 1 'Manual
ScrollBars = 3 'Both
TabIndex = 0
Top = 60
Width = 6375
End
Begin VB.Label Cnumb
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1080
TabIndex = 4
Top = 5100
Width = 1155
End
Begin VB.Label Label3
Caption = "中文字数:"
Height = 255
Left = 180
TabIndex = 3
Top = 5100
Width = 915
End
Begin VB.Label Enumb
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 1080
TabIndex = 2
Top = 4620
Width = 1155
End
Begin VB.Label Label1
Caption = "英文字数:"
Height = 255
Left = 180
TabIndex = 1
Top = 4620
Width = 915
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 s As String, temp As String
Dim i As Integer, e As Integer, c As Integer
s = Text1.text
c = 0
e = 0
For i = 1 To Len(s)
temp = Mid$(s, i, 1)
If Asc(temp) >= 33 And Asc(temp) <= 126 Then
e = e + 1
Else
If Asc(temp) < 0 Then
c = c + 1
End If
End If
Next i
Enumb.Caption = CStr(e)
Cnumb.Caption = CStr(c)
End Sub
Private Sub Command2_Click()
Text1.text = ""
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Data.GetFormat(vbCFText) Then
Text1.text = Data.GetData(vbCFText)
End If
If Data.GetFormat(vbCFFiles) Then
Dim vfn
For Each vfn In Data.Files
DropFile Text1, vfn
Next vfn
End If
End Sub
Private Sub Text1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)
If Data.GetFormat(vbCFText) Or Data.GetFormat(vbCFFiles) Then
Effect = vbDropEffectCopy And Effect
Exit Sub
End If
Effect = vbDropEffectNone
End Sub
Sub DropFile(ByVal text As TextBox, ByVal strfn$)
Dim iFile As Integer
iFile = FreeFile
Open strfn For Input Access Read Lock Read Write As #iFile
Dim str$, strline$
While Not EOF(iFile) And Len(str) <= 32000
Line Input #iFile, strline$
Debug.Print strline
If str <> "" Then str = str & vbcflf
str = str & strline
Wend
Close #iFile
text.SelStart = Len(text)
text.SelLength = 0
text.SelText = str
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -