Validation problem

  • Thread starter Thread starter Niklas Östrergren
  • Start date Start date
N

Niklas Östrergren

Hi!

I´m trying to validate input data from the user where the user specify a
break date (ex. 1 of september each year) for free membership.

This is what it´s all about:
If a new person pay membership fee for current year same day or after the
break day then shall the membership also be valid for not only current year
but also for the next year.

The user can select, set, this break date in setup fot the assosiation. The
break date is stored as a string:
Ex: 0109 = 1 of september.

Now to my problem:
The validation I have (see code below) works just fine BUT not if the user
tryes to set the dates to ex. 0009.

The validation I need to do is that the user enters a valid day which is
between 1-31 and valid mounth which is between 1-12. But the code I have
below fails to validate if the user enters 0 (zero) for either the day or
the mounth. If the user enters lower value (ex.-1) or higher (ex. 13 for the
mounth and 32 for the day) then it works just fine but NOT 0 (zero).

Any help are appreciated!

TIA
// Niklas

'===========================================
'Seperate break date into day and month
'===========================================
strBreakDay = Trim$(Left$(strBreakDate, 2))
strBreakMonth = Trim$(Right$(strBreakDate, 2))

'================================================
' Check if BreakDay and BreakMonth are valid
'================================================
If CInt(strBreakDay) < 1 Or CInt(strBreakDay) > 31 Then
MsgBox "En månad består av max 31 dagar" & vbCrLf _
& "och du har angett: " & strBreakDay & " dagar." & vbCrLf _
& "Ange en dag inom intervallet 1 - 31.", vbInformation +
vbOKOnly, "Ogiltigt datum (dag)"
ValidateBreakDateForNewFreeMembership = False
GoTo Exit_Procedure
End If

If CInt(strBreakMonth) < 1 Or CInt(strBreakMonth) > 12 Then
MsgBox "Ett år består av 12 månader" & vbCrLf _
& "och du har angett månad: " & strBreakMonth & "." & vbCrLf
_
& "Ange en månad inom intervallet 1 - 12.", vbInformation +
vbOKOnly, "Ogiltigt datum (månad)"

ValidateBreakDateForNewFreeMembership = False
GoTo Exit_Procedure
End If
 
See my answer to your later post, with subject "Validation problem!" posted Friday, December 17,
2004 7:22 AM.

Tom
_______________________________________________


Hi!

I´m trying to validate input data from the user where the user specify a
break date (ex. 1 of september each year) for free membership.

This is what it´s all about:
If a new person pay membership fee for current year same day or after the
break day then shall the membership also be valid for not only current year
but also for the next year.

The user can select, set, this break date in setup fot the assosiation. The
break date is stored as a string:
Ex: 0109 = 1 of september.

Now to my problem:
The validation I have (see code below) works just fine BUT not if the user
tryes to set the dates to ex. 0009.

The validation I need to do is that the user enters a valid day which is
between 1-31 and valid mounth which is between 1-12. But the code I have
below fails to validate if the user enters 0 (zero) for either the day or
the mounth. If the user enters lower value (ex.-1) or higher (ex. 13 for the
mounth and 32 for the day) then it works just fine but NOT 0 (zero).

Any help are appreciated!

TIA
// Niklas

'===========================================
'Seperate break date into day and month
'===========================================
strBreakDay = Trim$(Left$(strBreakDate, 2))
strBreakMonth = Trim$(Right$(strBreakDate, 2))

'================================================
' Check if BreakDay and BreakMonth are valid
'================================================
If CInt(strBreakDay) < 1 Or CInt(strBreakDay) > 31 Then
MsgBox "En månad består av max 31 dagar" & vbCrLf _
& "och du har angett: " & strBreakDay & " dagar." & vbCrLf _
& "Ange en dag inom intervallet 1 - 31.", vbInformation +
vbOKOnly, "Ogiltigt datum (dag)"
ValidateBreakDateForNewFreeMembership = False
GoTo Exit_Procedure
End If

If CInt(strBreakMonth) < 1 Or CInt(strBreakMonth) > 12 Then
MsgBox "Ett år består av 12 månader" & vbCrLf _
& "och du har angett månad: " & strBreakMonth & "." & vbCrLf
_
& "Ange en månad inom intervallet 1 - 12.", vbInformation +
vbOKOnly, "Ogiltigt datum (månad)"

ValidateBreakDateForNewFreeMembership = False
GoTo Exit_Procedure
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Validation problem! 1
Validation problem (again) 1

Back
Top