VB编程从文件输入一行以#为结束标志的字符串,将大小写字母互换,其他

2024-11-26 13:45:38
推荐回答(1个)
回答1:

Private Sub Command1_Click()
Open "d:\0.txt" For Input As #1
Open "d:\abc.txt" For Output As #2
Dim c As String, c1 As String
c = " "
Do While c <> "#"
Line Input #1, c1
For i = 1 To Len(c1)
c = Mid(c1, i, 1)
If c = "#" Then Exit Do
Print c;
If c >= "A" And c <= "Z" Then
c = Chr(Asc(c) + 32)
Else
If c >= "a" And c <= "z" Then
c = Chr(Asc(c) - 32)
End If
End If
Print #2, c;
Next i
Loop
Close #1
Close #2
Print
Print "OK!!"
End Sub