Show Data With Outlook Grid

You can easily create a calendar grid similar to the one in Outlook to show data. First, start a VB project, then place an MSFlex Grid on the form, with two textboxes to set the start and end dates and a command button to populate the grid. Paste this code in the Form1 code pane:

  Private Sub Command1_Click()     Dim ldBegDate As Date     Dim ldEndDate As Date     Dim lsMonth As String     Dim li, lsStr, lsStartDate, _          lsEndDate, liStartRow, _          liEndRow, liCnt, lsDate, liX     ldBegDate = Format(Text1, _          "mm/dd/yyyy")     ldEndDate = Format(Text2, _          "mm/dd/yyyy")     MSFlexGrid1.Clear: _          MSFlexGrid1.Cols = 5: _          MSFlexGrid1.Rows = 1: _          MSFlexGrid1.RowHeightMin _          = 800     For li = 0 To DateDiff("M", _          ldBegDate, ldEndDate)          lsMonth = Format(DateAdd("m", _               li, ldBegDate), "mmmyyyy")          '== check what month is being           '== processed          lsStartDate = "": lsEndDate = ""          '== Starting Month          If InStr(1, lsMonth, _               Format(ldBegDate, _               "mmmyyyy")) _               Then lsStartDate = ldBegDate          '== Ending Month          If InStr(1, lsMonth, _               Format(ldEndDate, _               "mmmyyyy")) _               Then lsEndDate = ldEndDate          '== Neither Starting or Ending           '== Month          If lsStartDate = "" Then _               lsStartDate = _               Format(DateAdd("m", li, _               ldBegDate), "mm/01/yyyy")          If lsEndDate = "" Then _               lsEndDate = _               Format(DateAdd("m", 1, _               Format(lsStartDate, _               "mm/01/yyyy")) - 1, _               "mm/dd/yyyy")          liStartRow = MSFlexGrid1.Rows          liEndRow = liStartRow + _               DateDiff("d", lsStartDate, _               lsEndDate)          MSFlexGrid1.Rows = _               MSFlexGrid1.Rows + _               liEndRow - liStartRow + 1          MSFlexGrid1.Col = 0          '== Put Dates in grid          For liCnt = 0 To DateDiff("d", _               lsStartDate, lsEndDate)               lsDate = DateAdd("d", liCnt, _                    lsStartDate)               MSFlexGrid1.Row = liStartRow _                    + liCnt               MSFlexGrid1.Text = lsDate               MSFlexGrid1.CellFontSize = _                    10: _                    MSFlexGrid1.CellFontBold _                    = True               MSFlexGrid1.CellAlignment = _                    flexAlignCenterCenter               If WeekDay(lsDate, vbMonday) _                    > 5 Then                    For liX = 1 To _                         MSFlexGrid1.Cols - 1                         MSFlexGrid1.Col = liX                         MSFlexGrid1.CellBackColor = _          &HC0C0C0:   _          MSFlexGrid1.CellForeColor _          = &H80000015                    Next                    MSFlexGrid1.Col = 0               End If          Next     Next '== li..Start to End DateEnd Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS