编写输出所有字符串子串的VB程序,实现如下功能:在文本框Text1中输入一串不重复的字符串,单击命令按钮“子串”Command1后,在列表框List1中输出该字符串的所有子串和子串的总数。程序运行界面如图所示,VB程序代码如下。
程序代码中,语句加框处有错,请改正。
Private Sub Command1_Click()
Dim s As String, sum As Integer
Dim i As Integer, j As Integer
List1.Clear
s = Text1.Text
n = len(s)
’(1)
For i = 1 To n
For j = 1 To n-i+1
List1.AddItem ’(2)
sum = sum + 1
Next j
Next i
List1.AddItem "总共有" + Str(sum) + "个子串"
End Sub
⑴{#blank#}1{#/blank#} ⑵{#blank#}2{#/blank#}