图中的vb题目如何做
Dim n As Integer, sum As Integer
Private Sub Command1_Click()
Dim a(20) As Integer
List1.Clear
Label1.Caption = ""
k = 0
If n = 0 Then List2.Clear
For i = 1 To 20
a(i) = Rnd * 501 + 100
List1.AddItem a(i)
yes = True
For j = 2 To Sqr(a(i))
If a(i) Mod j = 0 Then
yes = False
Exit For
End If
Next j
If yes Then k = k + 1
Next i
n = n + 1
sum = sum + k
List2.AddItem "第" & n & "组:" & k & "个素数"
End Sub
Private Sub Command2_Click()
Label1.Caption = n & "组,共" & sum & "个"
n = 0
sum = 0
End Sub
Private Sub Form_Load()
Label1.Caption = ""
End Sub
朋友,为什么程序中if语句中,没有end if 做结束语句。
还有sum 没有赋初始值,可以直接sum =sum +k吗
初学者,请多多指教。谢谢!