代码:
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
设计界面:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/a71ea8d3fd1f4134e5eb06f9291f95cad0c85e5c?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
运行界面:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/83025aafa40f4bfb54ad9cd30f4f78f0f7361833?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/faf2b2119313b07ee994528f00d7912397dd8c0f?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)