Page 1 of 1

uf_populate_year_ddlb() to populate a DDLB with years

PostPosted: 12 Jul 2019, 11:19
by Ursego
Code: Select all
/***********************************************************************************************************************************************
Dscr:         Populates Code Table of DrpDownListBox with years in descendant order beginning from the current year.
************************************************************************************************************************************************
Arg:         adwo_year - DWObject with DDLB of years
            ai_how_many_years - number of years in DDLB
            ab_allow_emptify - if true, then an empty row will be inserted to the DDLB; user can select that row to make the field empty.
************************************************************************************************************************************************
Developer:   Michael Zuskin > http://linkedin.com/in/zuskin | http://code.intfast.ca/
***********************************************************************************************************************************************/
int      li_curr_year
int      i
string   ls_year
string   ls_values

li_curr_year = Year(Today())

// Build string to assign to "Values" property of adwo_year.
// String format: "<display val1>~t<data val1>/<display val2>~t<data val2>/...<display valN>~t<data valN>/"
// Example if currently it's 2019 and ai_how_many_years = 5: "2019~t2019/2018~t2018/2017~t2017/2016~t2016/2015~t2015/".

if ab_allow_emptify then
   ls_values = " ~t0/" // insert empty string to the DDLB; user can select that row to make the field empty
end if

for i = 1 to ai_how_many_years
   ls_year = String(li_curr_year - i + 1)
   ls_values += ls_year + "~t" + ls_year + "/"
next

adwo_year.Values = ls_values

return