jwbf.net
当前位置:首页 >> vB中找出句子中最长单词,怎么出错了,提示无效的... >>

vB中找出句子中最长单词,怎么出错了,提示无效的...

把i = InStr(s, "")改为i = InStr(s, " ")

Private Sub Command1_Click() Dim Word() As String, LongestWord As String, LongestWordLength As Integer Word = Split(Left(Text1.Text, Len(Text1.Text) - 1), " ") LongestWordLength = 0 For i = LBound(Word) To UBound(Word) If Len(W...

参考示例: Dim strSentence As String, strTemp As String, strWord() As StringDim i As Integer' 大写转小写,去掉前后两端空格和回车符strTemp = Trim(Replace(LCase(Text1.Text), vbCrLf, ""))' 去掉非英文、空格的字符For i = 0 To Len(st...

Private Sub Command1_Click() Dim s As String, s1 As String, sm As String Dim L As Integer s = Text1.Text For i = 1 To Len(s) If Mid(s, i, 1) " " Then s1 = s1 & Mid(s, i, 1) Else If Len(s1) > Len(sm) Then sm = s1 s1 = "" End If ...

Private Sub Command1_Click() If Text1.Text = "" Then Exit Sub Dim word As Variant, s As String Dim k As Integer, maxw As String, n As Integer s = Replace(Replace(Text1.Text, ",", " "), ".", " ") s = Replace(Replace(s, ",", " "...

to attain to a higher conception.

Private Sub Command1_Click()Dim a() As Stringa = Split(Text1.Text, " ")Text2.Text = UBound(a) + 1End Sub细节自已调整。。。

dim ss as string dim lstr as string lstr=text1.text if right(lstr,1)="." then lstr=left(lstr,len(lstr)-1) end if ss=lword(lstr) text2.text=ss text3.text=len(ss)

将 If Len(Trim(arr(i))) > n Then n = i 改为 If Len(Trim(arr(i))) > Len(Trim(arr(n))) Then n = i 试试

split分割 得到各个单词 定义2个变量 ml长度 as long ms单词 as string 然后进行循环每个单词 得到最长的值和单词 这是思路..自己写代码..

网站首页 | 网站地图
All rights reserved Powered by www.jwbf.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com