这道题VB程序设计怎么做?

2024-12-17 03:03:34
推荐回答(1个)
回答1:

Option Explicit

Private Sub Command1_Click()

Text1.Text = ""

Label2.Caption = ""

Dim sum As Integer

Dim i As Integer

For i = 0 To 9

If List1.List(i) Mod 2 = 0 Then

If Text1.Text = "" Then

Text1.Text = List1.List(i)

Else

Text1.Text = Text1.Text & "  " & List1.List(i)

End If

sum = sum + Val(List1.List(i))

End If

Next i

Label2.Caption = sum

End Sub

Private Sub Form_Load()

Text1.Text = ""

Label2.Caption = ""

List1.Clear

Dim i As Integer

For i = 0 To 9

Randomize

List1.AddItem Int(Rnd * (99 - 10 + 1)) + 10, i

Next i

End Sub