VB编一子过程MaxLength(s,MaxWord),在字符串s中,找出最长单词
PrivateSubCommand1_Click()Callmaxlength(Text1,n)Text2=nEndSubSubmaxlength(s,maxword)F...
Private Sub Command1_Click()
Call maxlength(Text1, n)
Text2 = n
End Sub
Sub maxlength(s, maxword)
For n = 1 To 10000
maxword = ""
i = InStr(s, " ")
word = Left(s, i - 1)
If Len(word) > Len(maxword) Then
maxword = word
s = Mid(s, i + 1)
End If
Next n
End Sub
这个程序哪里错了??
谢谢 展开
Call maxlength(Text1, n)
Text2 = n
End Sub
Sub maxlength(s, maxword)
For n = 1 To 10000
maxword = ""
i = InStr(s, " ")
word = Left(s, i - 1)
If Len(word) > Len(maxword) Then
maxword = word
s = Mid(s, i + 1)
End If
Next n
End Sub
这个程序哪里错了??
谢谢 展开
1个回答
展开全部
Private Sub Command1_Click()
Call maxlength(Text1, n)
Text2 = n
End Sub
Sub maxlength(s, maxword)
maxword = ""
For n = 1 To 10000
i = InStr(s, " ")
If i = 0 And Len(s) > 0 Then i = Len(s) + 1
word = Left(s, i - 1)
If Len(word) > Len(maxword) Then
maxword = word
End If
If i >= Len(s) Then Exit For
s = Right(s, Len(s) - i)
Next n
End Sub
Call maxlength(Text1, n)
Text2 = n
End Sub
Sub maxlength(s, maxword)
maxword = ""
For n = 1 To 10000
i = InStr(s, " ")
If i = 0 And Len(s) > 0 Then i = Len(s) + 1
word = Left(s, i - 1)
If Len(word) > Len(maxword) Then
maxword = word
End If
If i >= Len(s) Then Exit For
s = Right(s, Len(s) - i)
Next n
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询