vb小白求解释一段代码 各位高人求指教!!!!
PrivateSubCommand2Click()DimnAsInteger,tAsString,wordnumAsIntegern=Len(s):t=""Fori=1T...
Private Sub Command2 Click()
Dim n As Integer, t As String, word num As Integer
n = Len(s): t = ""
For i = 1 To n
c = Mid(s, i, 1)
If c <> " " Then
t = t + c
Else
If foundhuiwen(t) Then
word num = word num + 1
End If
t = ""
End If
Next i
Text1.Text = word num
End Sub 展开
Dim n As Integer, t As String, word num As Integer
n = Len(s): t = ""
For i = 1 To n
c = Mid(s, i, 1)
If c <> " " Then
t = t + c
Else
If foundhuiwen(t) Then
word num = word num + 1
End If
t = ""
End If
Next i
Text1.Text = word num
End Sub 展开
3个回答
展开全部
Private Sub Command2_Click()
Dim n As Integer, t As String, word_num As Integer '定义几个变量
n = Len(s): t = "" 'n赋值为变量s的字符数;t赋值为空
For i = 1 To n '以i为循环变量循环
c = Mid(s, i, 1) '遍历s的每一个字符,用c暂时记录
If c <> " " Then '如果c不是空格
t = t + c 't就将c并入其后面
Else '否则
If foundhuiwen(t) Then '###############
word_num = word_num + 1 '###############
End If '###############
t = "" '将t重新置空
End If '
Next i '下一个
Text1.Text = word_num '文本框重新赋值
End Sub
【由于核心函数foundhuiwen不知道,所以无法推断代码功能】
Dim n As Integer, t As String, word_num As Integer '定义几个变量
n = Len(s): t = "" 'n赋值为变量s的字符数;t赋值为空
For i = 1 To n '以i为循环变量循环
c = Mid(s, i, 1) '遍历s的每一个字符,用c暂时记录
If c <> " " Then '如果c不是空格
t = t + c 't就将c并入其后面
Else '否则
If foundhuiwen(t) Then '###############
word_num = word_num + 1 '###############
End If '###############
t = "" '将t重新置空
End If '
Next i '下一个
Text1.Text = word_num '文本框重新赋值
End Sub
【由于核心函数foundhuiwen不知道,所以无法推断代码功能】
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询