7,765
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
Dim arr() As String
Dim strFile As String
Dim X as Long, i As Long, s As Long
arr = Split(Text2.Text, vbCrLf) '这里的 Text2 是指你所说的 TextBox
For X = 0 To UBound(arr)
strFile = arr(X)
If Len(strFile) > 20 Then
i = i + 1
Else
s = s + 1
End If
Next X
Text1.Text = i & vbCrLf & s
End Sub
Private Sub Command1_Click()
Dim arr() As String
Dim strFile As String
Open "c:\1.txt" For Input As #1
Do
Line Input #1, strFile
If Len(strFile) > 20 Then
i = i + 1
Else
s = s + 1
End If
Loop While Not EOF(1)
Text1.Text = i & vbCrLf & s
Close #1
End Sub
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const EM_GETLINECOUNT = &HBA
Private Sub Command1_Click()
LineCnt = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
MsgBox LineCnt
End Sub
Private Function vSpace(Vstring As String) As String
Do While InStr(Vstring, Chr(32)) <> 0
Vstring = Replace(Vstring, Chr(32), "")
Loop
vSpace = Vstring
End Function
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
xx = vSpace(a)
If xx = "" Then
MsgBox "文本共0行"
Else
yy = InStr(xx, Chr(10))
Select Case yy
Case 0
MsgBox "文本共1行"
Case Else
j = 0
zz = Split(xx, Chr(10))
For i = 0 To UBound(zz)
If zz(i) <> Chr(13) Then
Debug.Print zz(i)
j = j + 1
End If
Next
MsgBox "文本共" & j & "行"
End Select
End If
End Sub