vb统计字符串中英文字母的个数并输出
答案:1 悬赏:0 手机版
解决时间 2021-02-25 01:05
- 提问者网友:鼻尖触碰
- 2021-02-24 02:57
vb统计字符串中英文字母的个数并输出
最佳答案
- 五星知识达人网友:冷風如刀
- 2021-02-24 03:10
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
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
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯