Visual Basic 2012 (VB) Create a list of the months of the year separated by comm
ID: 656458 • Letter: V
Question
Visual Basic 2012 (VB)
Create a list of the months of the year separated by commas and store into a variable called MonthsList.
Use the Split function to parse the month names into an Array called ArrayMonths.
Print the Array starting from ArrayMonths (0) thru ArrayMonths(11) into a list box.
Create a datafile using Notepad with records that contain the months of the year. The word January is one record followed by a second record that contains February and so forth. There will be 12 rows in the file. Do not press enter when you type December. Just type it in and save the file as MonthsOfYear.
Store the
Explanation / Answer
$months = arr(
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul ',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
);
$current = date('F');
$start = array($current, $months);
$toshow = array();
$sum = 0;
for($k = $start; $sum < 8; $k--)
{
if($k == 0)
{
$k = 12;
}
function formDay()
{
for($k=1; $k<=31; $k++)
{
$selected = ($k==date('n'))? ' selected' :'';
echo '<option'.$selected.' value="'.$k.'">'.$k.'</option>'." ";
}
}
$toshow[] = $months[$k];
$sum++;
}
var_temp($toshow);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.