急求vb程序设计教程答案,在线等 示在文本框Text2,完成下列程序代码。

来源:百度知道 编辑:UC知道 时间:2024/06/05 06:28:19
窗体上含有2个文本框(Text1及Text2).一个列表框(List1)和一个命令按钮

(command1).程序运行之后,用户在文本框Text1中输入一个字符串,其中包含若

干个英文单词,单词之间用空格分割。单击命令按钮后,分解出这些单词,并一

次现实在列表框List1中,单词个数显示在文本框Text2,完成下列程序代码。
Private Sub Command1_Clikc()
Dim s As String
s=trim(text1,text)
n=Getword(s)
text2.text=n
End Sub
Function Getword(s As STring) AS Integer
List1.clear
Do While______________________________
P=instr(s,Space(1))
If p=o Then
list.additem s
s=``````
Else
List1.Additem Left(s,p-1)
s=_____________________
End If
Loop
Getwprd=_______________________________
End Function

Private Sub Command1_Click()
Dim s As String
s = Trim(Text1.Text)
n = Getword(s)
Text2.Text = n
End Sub
Function Getword(s As String) As Integer
List1.Clear
Do While s <> ""
p = InStr(s, Space(1))
If p = 0 Then
List1.AddItem s
s = "": Getword = Getword + 1
Else
List1.AddItem Left(s, p - 1)
s = Right(s, Len(s) - p): Getword = Getword + 1
End If
Loop
Getword = Getword
End Function