For i = 1 to 100 Next i problem

jaanisf

Registered User.
Local time
Today, 03:32
Joined
Apr 29, 2003
Messages
32
If my labels' names are d1, d2, d3, etc.., how should I handle this?

4th row needs to be handled differently, but how?

Private Sub btnshod_Click()
Dim di
For di = 1 To 27
Me!d & (di + 5) &.Caption = Left(Date + di, 2)
Next di
End Sub
 
Private Sub btnshod_Click()
Dim di
For di = 1 To 27
Me("d" & di + 5).Caption = Left(Date + di, 2)
Next di
End Sub

found it by myself, never mind ;)
 
Good to see but since I had to build it for testing your going to get it anyhow. :D

I've changed some of the name to include a naming convention.
If you don't want to use them then you can remove them where necessary.
I think that Left(Date + di, 2) will truncate the slash when Date + di > 9

Code:
Option Explicit
Option Compare Text


Private Sub btnShod_Click()
    Dim lngDi As Long
    
    For lngDi = 1 To 27
        Me("lblD" & CStr(lngDi + 5)).Caption = Left$(Date + lngDi, InStr(Date + lngDi, "/"))
    Next lngDi
    
End Sub
Hope that helps or at least gets you started.

Regards
Chris
 

Users who are viewing this thread

Back
Top Bottom