Preceed with zero and Concatenate
Posted by BeverleyB on November 08, 2001 7:16 AM
Hi Guys,
Could anyone check this code and see if you could assist me please. (Joe Chin provided it and I just had to make one correction)
private function convertdate(intmonth as integer,intyear as integer) as string
dim strnewdate asstring *4
dim intnewmonth as integer
dim strnewmonth as string *2
dim intnewyear as integer
dim strnewyear as string *2
dim intnewdate as integer
if intmonth >10 then
intnewmonth=intmonth +3
intnewyear=intyear
else
intnewmonth=intmonth -9
intnewyear=intyear+1
end if
strnewmonth=cstr(intnewmonth)
strnewyear=cstr(intnewyear)
strnewdate=strnewyear & strnewmonth
convertdate=strnewdate
end sub
Private sub commandbutton1_Click()
txtyearmonth.text=convertdate(txtmonth.text,txtyear.text)
end sub
Everything works well up to the point where the data goes into txtyearmonth. If the month is less than 9 it has to be preceeded with a zero but i am at a loss as how to get this done for both the month and year.
The data also has spaces separating the month and the year and they should be 4 numbers. If the date is 30/09/01 my data should be 0112 but it looks like 1 12, can anyone offer any assistance?
Thanks
Bev