hi all
im trying to get rid of a lot of usless code in this programe im redoing
what i have is two arrow keys a forward and backwards arrow
what they do is move the date or nonth foreward or backwards.
here is the code

code for the keys

VB Code:
  1. Public Sub mnuNext_Click()
  2.     Change_Day_Month (True)
  3. End Sub
  4.  
  5. Public Sub mnuPrevious_Click()
  6.     Change_Day_Month (False)
  7. End Sub

main code

VB Code:
  1. Public Sub Change_Day_Month(Forward As Boolean)
  2.  
  3. Dim leap As Integer
  4. Dim lastday As Integer
  5. Dim nmonth As Integer
  6. Dim nday As Integer
  7. Dim nyear As Integer
  8. Dim cyear As Integer
  9. Dim Add_day As Integer
  10.  
  11. numdays = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) 'number days in month
  12.  
  13. If Forward Then
  14.   Add_day = 1
  15. Else
  16.   Add_day = -1
  17. End If
  18.  
  19. cyear = iyear
  20. leap = cyear - (cyear \ 4) * 4 'for leap year, leap=0
  21. lastday = numdays(imonth) 'last day of month
  22. If ((leap = 0) And (imonth = 2)) Then lastday = lastday + 1
  23. '
  24. If Not (cmdProgram.Value) Then
  25.  nday = iday + Add_day
  26.  If (nday > lastday) Or (nday < 1) Then
  27.    If (nday > lastday) Then
  28.      nday = 1
  29.      nmonth = imonth + Add_day
  30.    ElseIf (nday < 1) And (imonth = 1) Then
  31.      nmonth = 12
  32.      cyear = cyear + Add_day
  33.      nday = numdays(nmonth)
  34.    Else
  35.      nmonth = imonth + Add_day
  36.      nday = numdays(nmonth)
  37.    End If
  38.  Else
  39.   nmonth = imonth
  40.  End If
  41.  If (nmonth = 13) Or (nmonth = 0) Then
  42.    If (nmonth = 13) Then
  43.     nmonth = 1
  44.    Else
  45.     nmonth = 12
  46.    End If
  47.    nyear = cyear + Add_day
  48.  Else
  49.    nyear = cyear
  50.  End If
  51.  txtDay.Text = CStr(nday)
  52. Else 'Light Mode
  53.  nmonth = imonth + Add_day
  54.  nyear = cyear
  55.  If (nmonth = 13) Or (nmonth = 0) Then
  56.   If (nmonth = 13) Then
  57.     nmonth = 1
  58.   Else
  59.     nmonth = 12
  60.   End If
  61.   nyear = cyear + Add_day
  62.  End If
  63. End If
  64. '
  65. imonth = nmonth
  66. iday = nday
  67. iyear = nyear
  68. txtMonth.Text = Convert_Date_Int2Str(CInt(nmonth))
  69. txtyear.Text = CStr(nyear + 1900) 'add back 1900
  70.  
  71. Call run
  72.  
  73. End Sub

I have tride to use date picker but it does not fit or look goog in my form.

any help appriciated
ed