代码:
Private Sub Command1_Click()
Text4.Text = ""
Dim Sentence As String, strWord() As String, WordCount As Integer, RemainingWords() As String, RemainingWrodCount As Integer, ArticleCount As Integer, Punctuation As String
Sentence = InputBox("请输入一个英语语句,单词之间空一格,句尾加一个标点。", "输入框", "The word secretary comes from the same Latin root as the word secret.")
Text1.Text = Sentence
strWord = Split(Left(Sentence, Len(Sentence) - 1), " ")
Punctuation = Right(Sentence, 1)
WordCount = UBound(strWord) - LBound(strWord) + 1
Text2.Text = WordCount
For i = LBound(strWord) To UBound(strWord)
If strWord(i) <> "The" And strWord(i) <> "the" And strWord(i) <> "THE" Then
ReDim Preserve RemainingWords(RemainingWrodCount)
RemainingWords(RemainingWrodCount) = strWord(i)
RemainingWrodCount = RemainingWrodCount + 1
End If
Next i
ArticleCount = WordCount - UBound(RemainingWords) - 1
Text3.Text = ArticleCount
For i = LBound(RemainingWords) To UBound(RemainingWords) - 1
Text4.Text = Text4.Text + RemainingWords(i) + Space(1)
Next i
Text4.Text = Text4.Text + RemainingWords(UBound(RemainingWords)) + Punctuation
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
设计界面:
运行界面: