Spread 8.0 Documentation
Example
Support Options

Glossary Item Box

Example


The following example lets the user enter a pivot year and see the resulting range of dates that the control uses to assume which century to use when dealing with a two-digit year. If the user enters a two-digit year into the sheet, the sheet assumes that the correct four-digit year is the one that falls within the range of dates shown.

C++

void CmyWnd::MyFunc()
{
    // Give text boxes their initial values (default: 2059)
    SetDlgItemInt(IDC_TEXT1,fpSpread1.GetTwoDigitYearMax ());
    SetDlgItemInt(IDC_TEXT2,fpSpread1.GetTwoDigitYearMax ()-99);
    SetDlgItemInt(IDC_TEXT3,fpSpread1.GetTwoDigitYearMax ());

    // Set first row, first column cell as a date cell with four-digit year, wider column, and active cell
    fpSpread1.SetRow(1);
    fpSpread1.SetCol(1);
    fpSpread1.SetCellType(CellTypeDate);
    fpSpread1.SetColWidth(1,13);
    fpSpread1.SetEditMode(TRUE);
}

void CmyWnd::OnChange()
{
    // Assign new four-digit number to TwoDigitYearMax
    NewNo = GetDlgItemInt(IDC_TEXT1);
    fpSpread1.SetTwoDigitYearMax(NewNo);

    // Display new range
    SetDlgItemInt(IDC_TEXT2,fpSpread1.GetTwoDigitYearMax () - 99);
    SetDlgItemInt(IDC_TEXT3,fpSpread1.GetTwoDigitYearMax ());
}

Visual Basic

Dim NewNo

Sub Form_Load()
    ' Create labels on form
    Form1.Caption = "Pivot Year Range"
    Label1.Caption = "Type a four-digit pivot year:"
    Label2.Caption = "The sheet assumes that the century to display for a two-digit year falls within the range of your pivot year minus 99 years, as shown in the boxes below the control."
    Label3.Caption = "to"

    ' Give text boxes their initial values (default: 2059)
    Text1.Text = fpSpread1.TwoDigitYearMax
    Text2.Text = (fpSpread1.TwoDigitYearMax - 99)
    Text3.Text = fpSpread1.TwoDigitYearMax

    ' Set first cell to be a date cell with four-digit year, wider column, and active cell
    fpSpread1.Col = 1
    fpSpread1.Row = 1
    fpSpread1.CellType = CellTypeDate
    fpSpread1.TypeDateCentury = True
    fpSpread1.ColWidth(1) = 13
    fpSpread1.EditMode = True
End Sub

Sub Text1_Change()
    ' Assign new four-digit number to TwoDigitYearMax
    NewNo = Val(Text1.Text)
    fpSpread1.TwoDigitYearMax = NewNo

    ' Display new range
    Text2.Text = (fpSpread1.TwoDigitYearMax - 99)
    Text3.Text = fpSpread1.TwoDigitYearMax
End Sub

Copyright © GrapeCity, inc. All rights reserved.