Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Date Time Code Examples

Print a month-calender

Print a month-calender The user doesn't have to give all this input.. just the date. make a new project with a form and a command button Put the next code under the click event of the command button.. press f5 to run BTW: perhaps you have to make a change with the date-separator and the order (european = dd-mm-yy / american = mm-dd-yy). And of course to the output; it's now just straight forward! Private sub Command1_Click() dim StartDatum dim vMonth dim vYear dim StartDag dim vRow%, vColomn% Const t1% = 5 Const t2% = 10 Const t3% = 15 Const t4% = 20 Const t5% = 25 Const t6% = 30 dim c% dim GoFurther% startdatum = InputBox("which first date", , Format(Now, "dd-mm-yy")) If startdatum = "" Then Exit Sub vMonth = Month(StartDatum) vYear = Year(StartDatum) startdatum = CDate("1-" & vMonth & "-" & vYear) StartDag = DatePart("w", StartDatum) '1=sunday '2=monday 'etc GoFurther% = False Printer.Print StartDatum Printer.Print "S"; Tab(t1); "M"; Tab(t2); "T"; Tab(t3); "W"; _ Tab(t4); "T"; Tab(t5); "F"; Tab(t6); "S" Screen.MousePointer = vbHourglass For vRow% = 1 To 6 For vColomn% = 1 To 7 If (StartDag = vColomn% And Not GoFurther%) Then c% = 1 Printer.Print Str(c%); GoFurther% = True Else If (GoFurther% And IsDate(CStr(c%) & "-" & vMonth & _ "-" & vYear)) Then Printer.Print Str(c%); end If select case vColomn% case 1 Printer.Print Tab(t1); case 2 Printer.Print Tab(t2); case 3 Printer.Print Tab(t3); case 4 Printer.Print Tab(t4); case 5 Printer.Print Tab(t5); case 6 Printer.Print Tab(t6); end Select c% = c% + 1 Next vColomn% Printer.Print Next vRow% Printer.EndDoc Screen.MousePointer = vbNormal End Sub Return