function valid_date(tmp_object)
	dim li_year, li_month, li_day, li_len, li_st, li_flag, li_m_st, ls_ok, ldt_date
	
	tmp_value = tmp_object.value
	li_len = len(tmp_value)
	ls_ok = "T"
	if isdate(tmp_value) = false then
			call msgbox ("not valid format", ,"Library Master 5.0 - Message Box")
			tmp_object.focus
			ls_ok = "F"
			valid_date = false
	end if

	li_st = 1
	li_flag = "T"
	if ls_ok = "T" then
		while li_flag = "T" and li_st <= li_len
			if mid(tmp_value, li_st, 1) = "/" then
				li_flag = "F"
				if li_st = 1 or li_st > 3 then
					call msgbox ("not valid day format", ,"Library Master 5.0 - Message Box")
					tmp_object.focus
					ls_ok = "F"
					valid_date = false
				else
					li_day = mid(tmp_value, 1, li_st-1)
				end if
			end if
			li_st = li_st + 1 
		wend
	end if
	if ls_ok = "T" then
		li_m_st = li_st
		li_flag = "T"
		while li_flag = "T" and li_m_st <= li_len 
			if mid(tmp_value, li_m_st, 1) ="/" then
				li_flag = "F"
				if li_m_st = li_st or li_m_st > 6 then
					call msgbox ("not valid month format", ,"Library Master 5.0 - Message Box")
					tmp_object.focus
					ls_ok = "F"
					valid_date = false
				else
					li_month = mid(tmp_value, li_st , li_m_st - li_st)
				end if
			end if
			li_m_st = li_m_st + 1
			
		wend
	end if
	if ls_ok = "T" then
		li_m_st = li_m_st
		li_year = mid(tmp_value, li_m_st)
		if len(li_year) < 1 then
			call msgbox ("not valid year format", ,"Library Master 5.0 - Message Box")
			tmp_object.focus
			ls_ok = "F"
			valid_date = false
		end if
	end if	
	
	ldt_date = dateserial(cint(li_year), cint(li_month), cint(li_day))
	if ls_ok = "T" then
		if not isdate(tmp_value) then
			call msgbox ("not valid date format", ,"Library Master 5.0 - Message Box")
			tmp_object.focus
			valid_date = false
		else
			li_year = year(ldt_date)
			li_month= month(ldt_date)
			if li_month < 10 then 
				li_month = "0" & li_month
			end if
			li_day= day(ldt_date)
			if li_day < 10 then
				li_day = "0" & li_day
			end if
			
			tmp_value = li_day & "/" & li_month & "/" & li_year
			tmp_object.value = tmp_value
			valid_date = true
		end if
	end if
end function


function valid_number(tmp_object)
	tmp_value = tmp_object.value
	if not isNumeric(tmp_value) then
		call msgbox ("not valid number format", ,"Library Master 5.0 - Message Box")
		tmp_object.focus
		valid_number = false
	end if
end function

function valid_num_mml(tmp_object, tmp_min, tmp_max)
	tmp_value = tmp_object.value
	if not isNumeric(tmp_value) then
		call msgbox ("not valid number format", ,"Library Master 5.0 - Message Box")
		tmp_object.focus
		valid_num_mml = false
	elseif cint(tmp_value) < tmp_min then
		call msgbox ("Not valid range! Number too small", ,"Library Master 5.0 - Message Box")
		tmp_object.focus
		valid_num_mml = false
	elseif cint(tmp_value) > tmp_max then
		call msgbox ("not valid range! Number too large", ,"Library Master 5.0 - Message Box")
		tmp_object.focus
		valid_num_mml = false
	end if
end function

function valid_str_mml(tmp_object, tmp_min, tmp_max)
	tmp_value = len(tmp_object.value)
	if  tmp_value < tmp_min then
		call msgbox ("Not valid string lenght! Too short", ,"Library Master 5.0 - Message Box")
		tmp_object.focus
		valid_str_mml = false
	elseif tmp_value > tmp_max then
		call msgbox ("not valid string lenght! Too long", ,"Library Master 5.0 - Message Box")
		tmp_object.focus
		valid_str_mml = false
	end if
end function

function valid_rel_str(tmp_object1, tmp_object2)
	tmp_value1 = len(tmp_object1.value)
	tmp_value2 = len(tmp_object2.value)
	if  (tmp_value1 > 0 and tmp_value2 <= 0)  then
		call msgbox ("Empty value is not allowed", ,"Library Master 5.0 - Message Box")
		tmp_object2.focus
		valid_rel_str = false
	elseif (tmp_value1 = 0 )  then
		tmp_object2.value = ""
		valid_rel_str = true
	else
		valid_rel_str = true
	end if
end function

function valid_Sthan(tmp_object1, tmp_object2)
	if tmp_object1.value < tmp_object2.value then
	else
		call msgbox ("value should be greater", ,"Library Master 5.0 - Message Box")
			tmp_object2.focus
			valid_smallerthan = false
	end if
end function

function valid_SorEq(tmp_object1, tmp_object2)
	if tmp_object1.value <= tmp_object2.value then
	else
		call msgbox ("value should be greater", ,"Library Master 5.0 - Message Box")
			tmp_object2.focus
			valid_SorEq = false
	end if
end function

function valid_Date_SorEq(tmp_object1, tmp_object2)
	dim li_year, li_month, li_day, ldt_date1, ldt_date2
	
	tmp_value = tmp_object1.value
	li_day   = mid(tmp_value, 1, 2)
	li_month = mid(tmp_value, 4, 2)
	li_year  = mid(tmp_value, 7, 4)
	ldt_date1 = dateserial(cint(li_year), cint(li_month), cint(li_day))
	
	tmp_value = tmp_object2.value
	li_day   = mid(tmp_value, 1, 2)
	li_month = mid(tmp_value, 4, 2)
	li_year  = mid(tmp_value, 7, 4)
	ldt_date2 = dateserial(cint(li_year), cint(li_month), cint(li_day))

	if ldt_date1 <= ldt_date2 then
	else
		call msgbox ("value should be greater", ,"Library Master 5.0 - Message Box")
			tmp_object2.focus
			valid_Date_SorEq = false
	end if
end function