vb6.0 数组问题??
我想将定义两个数组a和b。
a=(1,2,3,5,7,11)
b=(4,6,8,9,10,12)
当text1.text=a时,text2.text="素数"
当text1.text=b时,text2.text="偶数"
用数组怎样定义啊?请写代码出来!谢谢!
[解决办法]
不是"偶数"是"合数"
Option ExplicitDim a, bPrivate Sub Form_Load() a = Array(1, 2, 3, 5, 7, 11) b = Array(4, 6, 8, 9, 10, 12) End SubPrivate Sub Text1_Change() Dim i As Integer, iNum As Integer If (IsNumeric(Text1.Text)) Then iNum = CInt(Text1.Text) Else Exit Sub End If For i = LBound(a) To UBound(a) If (iNum = a(i)) Then Text2.Text = "素数" Exit Sub End If Next i For i = LBound(b) To UBound(b) If (iNum = b(i)) Then Text2.Text = "合数" Exit Sub End If Next i Text2.Text = "都不是"End Sub