如何在label显示出listcount

来源:百度知道 编辑:UC知道 时间:2024/05/29 17:35:29
Dim n As Integer
Private Sub Command1_Click()
List1.Clear
Label1.Caption = "符合条件的个数为:" & list1.ListCount
n = Val(Text1.Text)
If (n Mod 7 <> 0) Then
listbox1.AddItem n
End If
End Sub

Private Sub Command2_Click()
List1.Clear
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Form_Load()
Show
Command1.Caption = "查看"
Command2.Caption = "清除"
Text1.Text = ""
Label1.Caption = ""
End Sub
程序运行后不能显示出计数的结果?

直接 Label1.Caption = list1.ListCount 就可以了!~

但是你的代码 写的有问题!~

你在给list添加记录以前显示list的count 所以为0 我给改到下面去了

Private Sub Command1_Click()
dim i as integer
i=i
List1.Clear
for n = 1 toval(text1.text)
If (n Mod 7 <> 0) Then
listbox1.AddItem i
i=i+1
End If
next
Label1.Caption = "符合条件的个数为:" & list1.ListCount
End Sub

list1.ListCount

查一下返回值类型。记得是INT。要转字符串吧。