输入一个英文句子,统计其中单词的个数,输出最长单词在文本中的位置(是文本中的第几个字符)和长度;

2024-12-02 16:39:10
推荐回答(4个)
回答1:

Private Sub maxlengthword(ByVal str1$, ByRef maxword$)
Dim i%
Dim temp$

i = InStr(str1, " ")
maxword = ""
Do While i > 0
temp = Mid(str1, 1, i - 1)
If Len(temp) > Len(maxword) Then maxword = temp
str1 = Mid(str1, i + 1)
i = InStr(str1, " ")
Loop
If Len(str1) > Len(maxword) Then maxword = str1
TextBox2.Text = maxword
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str1 As String, m As String
m = ""
str1 = TextBox1.Text
maxlengthword(str1, m)
End Sub

回答2:

无聊

回答3:

O(∩_∩)O~

回答4:

这个好像有例子