QUOTE(sonusan @ 27 Jun, 2009 - 09:40 PM)

Hello...I want to do a progra such that when ever i will choose month from combo box,in the frame those no. of days should enabled.I have used array of command buttons.I have attached my form .Here is my code but its not working at all.
CODE
Dim Index As Integer
Dim a As Integer
Private Sub Combo1_Change()
If Combo1.ListIndex = 0 Or 2 Or 4 Or 6 Or 7 Or 9 Or 11 Then
For Index = 0 To 30 Step 1
cmdd(Index).Enabled = True
End If
If Combo1.ListIndex = 3 Or 5 Or 8 Or 10 Then
For Index = 0 To 29 Step 1
cmdd(Index).Enabled = True
End If
a = Val(Format(Now, "yyyy"))
If Combo1.ListIndex = 1 Then
If Combo1.ListIndex = 1 And ((aMod4 = 0 And aMod100 <> 0) Or aMod400 = 0) Then
For Index = 0 To 28 Step 1
cmdd(Index).Enabled = True
End If
Else
For Index = 0 To 27 Step 1
cmdd(Index).Enabled = True
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Label2_Click()
End Sub
[quote]
Well, I guess you make 2 mistakes in your codes.
1. Like vb5prgrmr said that your "For" loops need to end with a "Next" statement
2. Your "If statement" for Februari had a wrong statement. It's better if you use a nested if.
Perhaps this could help you:
CODE
Dim Index As Integer
Dim a As Integer
Private Sub Combo1_Click()
If Combo1.ListIndex = 0 Or 2 Or 4 Or 6 Or 7 Or 9 Or 11 Then
For Index = 0 To 30 Step 1
cmdd(Index).Enabled = True
Next
End If
If Combo1.ListIndex = 3 Or 5 Or 8 Or 10 Then
For Index = 0 To 29 Step 1
cmdd(Index).Enabled = True
Next
End If
a = Val(Format(Now, "yyyy"))
If Combo1.ListIndex = 1 Then
If ((aMod4 = 0 And aMod100 <> 0) Or aMod400 = 0) Then
For Index = 0 To 28 Step 1
cmdd(Index).Enabled = True
Next
Else
For Index = 0 To 27 Step 1
cmdd(Index).Enabled = True
Next
End if
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Label2_Click()
End Sub
And I think it's better to use Click event than Change event for the combo box.
I hope it helps you.