엄청 간단한 것이라, 금방 할 줄 알았다.
그런데, emulator로 하니까, 날짜 형식이 9/9/06 식으로 나왔다. PDA에서는 06-9-9 식으로 지원되는데, 형식을 맞추거나 DateDiff 함수로 해봤으나, 년도의 위치가 달라 잘 안 됬다. 그래서 left, right 함수로 위치를 교정하려 했으나 실패했다. 2시간이 흘러서 난, PDA와 emulator가 분명 다를 것이라 생각하고, 도전했다. 결과는 성공적 이었다. 간단한 한 줄로 표현되었다.
-----------------마우스로 클릭하면, expire 텍스트 상자에는 해당 년월일이 표시되고, lateday에는 남은 날이 찍힌다.-------------------
Me.PoLateDay.Text = DateDiff("d", Me.Controls(CallingControl).Text, Date)
Private Sub picCal_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Double, ByVal y As Double)
Dim xCell As Integer
Dim yCell As Integer
Dim iDay As Integer
'마우스 왼쪽 버튼이 클릭되었는지 체크
Me.piccal.FillColor = vbWhite
If x > lButLeft And x < lButRight And y > lButTop And y < lButBottom Then
stDate = DateAdd("m", -1, stDate)
drawmonthname stDate
Me.piccal.DrawLine 0, HeaderMonthH + HeaderDaysH, piccal.ScaleWidth, piccal.ScaleHeight, vbBlack, True, False
FillArrayMonth stDate
Exit Sub
End If
'마우스 오른쪽 버튼이 클릭되었는지 체크
If x > rButLeft And x < rButRight And y > rButTop And y < rButBottom Then
stDate = DateAdd("m", 1, stDate)
drawmonthname stDate
Me.piccal.DrawLine 0, HeaderMonthH + HeaderDaysH, piccal.ScaleWidth, piccal.ScaleHeight, vbBlack, True, False
FillArrayMonth stDate
Exit Sub
End If
'년도를 스크롤하는 것을 클릭했는지 체크
If x > upButLeft And x < upButRight And y > upButTop And y < upButBottom Then
ButtonDirection = ButtonDirectionUp
Me.TimerYear.Interval = 50
Exit Sub
End If
'년도를 스크롤 다운 했는지 체크
If x > dnButLeft And x < dnButRight And y > dnButTop And y < dnButBottom Then
ButtonDirection = ButtonDirectiondn
Me.TimerYear.Interval = 50
Exit Sub
End If
'캘리더 자체가 클리되었는지 체크
If y > HeaderMonthH + HeaderDaysH Then
' iDay = (yCell - 1) * 7 + xCell
' If Not IsEmpty(aDateArray(iDay)) Then
If prevX <> 0 And prevY <> 0 Then
iDay = (prevY - 1) * 7 + prevX
If iDay Mod 7 <> 0 Then
Me.piccal.DrawLine ((prevX - 1) * DayCellWidth) + 10 + 15, ((prevY - 1) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, ((prevX) * DayCellWidth) - 10 + 15, ((prevY) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, vbWhite, True, True
Me.piccal.ForeColor = vbBlack
Me.piccal.DrawText aDateArray(iDay), (((iDay - 1) Mod 7) * DayCellWidth) + aDayWidth(aDateArray(iDay)) + 15, HeaderMonthH + HeaderDaysH + ((iDay - 1) 7) * DayCellHeight
Else
Me.piccal.DrawLine ((6) * DayCellWidth) + 10 + 15, ((prevY - 2) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, ((7) * DayCellWidth) - 10 + 15, ((prevY - 1) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, vbWhite, True, True
Me.piccal.ForeColor = vbBlack
Me.piccal.DrawText aDateArray(iDay), ((6) * DayCellWidth) + aDayWidth(aDateArray(iDay)) + 15, HeaderMonthH + HeaderDaysH + ((iDay - 2) 7) * DayCellHeight
End If
End If
xCell = ((x - 15) DayCellWidth) + 1
yCell = Fix((y - (HeaderMonthH + HeaderDaysH)) DayCellHeight) + 1
' If y > HeaderMonthH + HeaderDaysH Then
iDay = (yCell - 1) * 7 + xCell
If Not IsEmpty(aDateArray(iDay)) Then
DrawReverseDate xCell, yCell, prevX, prevY, iDay
Me.Controls(CallingControl).Text = FormatDateTime(DateSerial(Year(stDate), Month(stDate), aDateArray(iDay)), vbShortDate)
piccal.Visible = False
lstMonthNames.Visible = False
lblMonth.Visible = False
Me.PoLateDay.Text = DateDiff("d", Me.Controls(CallingControl).Text, Date)
End If
End If
End Sub
------------------------------------------------------------------------
If Not IsNull(gobjWork.Fields("PoLateDay").Value) Then
' 이름 설정
' Me.PoLateDay.Text = gobjWork.Fields("PoLateDay").Value
' DateDiff 함수를 이용해서 남은 날을 구한다.
Me.PoLateDay.Text = DateDiff("d", gobjWork.Fields("PoExpire").Value, Date)
End If
위 코드는 일전에 써 넣은 refresh form cd 함수에 있는 부분인데, cdb에서 꺼내온 날짜를 통해 lateday의 변경값을 다시 구한다. 변동적인 값이라, db에 저장하는 것은 의미가 없다. 하지만 field가 만들어져 있으니, 저장시 값으로 저장되어 있고, 그것이 있다면 expire day 기준으로 다시 저장하기 위해 고치는 것이다. 없다면, expire day도 설정이 안 된 것이니(첫번째 함수에 의하여 설정되므로 자동 값이다.) 이 정도는 버그로 치지 않아도 될 것 같다. 그냥 late day를 라벨로 바꿔버려야 겠다.
그런데, emulator로 하니까, 날짜 형식이 9/9/06 식으로 나왔다. PDA에서는 06-9-9 식으로 지원되는데, 형식을 맞추거나 DateDiff 함수로 해봤으나, 년도의 위치가 달라 잘 안 됬다. 그래서 left, right 함수로 위치를 교정하려 했으나 실패했다. 2시간이 흘러서 난, PDA와 emulator가 분명 다를 것이라 생각하고, 도전했다. 결과는 성공적 이었다. 간단한 한 줄로 표현되었다.
-----------------마우스로 클릭하면, expire 텍스트 상자에는 해당 년월일이 표시되고, lateday에는 남은 날이 찍힌다.-------------------
Me.PoLateDay.Text = DateDiff("d", Me.Controls(CallingControl).Text, Date)
Private Sub picCal_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Double, ByVal y As Double)
Dim xCell As Integer
Dim yCell As Integer
Dim iDay As Integer
'마우스 왼쪽 버튼이 클릭되었는지 체크
Me.piccal.FillColor = vbWhite
If x > lButLeft And x < lButRight And y > lButTop And y < lButBottom Then
stDate = DateAdd("m", -1, stDate)
drawmonthname stDate
Me.piccal.DrawLine 0, HeaderMonthH + HeaderDaysH, piccal.ScaleWidth, piccal.ScaleHeight, vbBlack, True, False
FillArrayMonth stDate
Exit Sub
End If
'마우스 오른쪽 버튼이 클릭되었는지 체크
If x > rButLeft And x < rButRight And y > rButTop And y < rButBottom Then
stDate = DateAdd("m", 1, stDate)
drawmonthname stDate
Me.piccal.DrawLine 0, HeaderMonthH + HeaderDaysH, piccal.ScaleWidth, piccal.ScaleHeight, vbBlack, True, False
FillArrayMonth stDate
Exit Sub
End If
'년도를 스크롤하는 것을 클릭했는지 체크
If x > upButLeft And x < upButRight And y > upButTop And y < upButBottom Then
ButtonDirection = ButtonDirectionUp
Me.TimerYear.Interval = 50
Exit Sub
End If
'년도를 스크롤 다운 했는지 체크
If x > dnButLeft And x < dnButRight And y > dnButTop And y < dnButBottom Then
ButtonDirection = ButtonDirectiondn
Me.TimerYear.Interval = 50
Exit Sub
End If
'캘리더 자체가 클리되었는지 체크
If y > HeaderMonthH + HeaderDaysH Then
' iDay = (yCell - 1) * 7 + xCell
' If Not IsEmpty(aDateArray(iDay)) Then
If prevX <> 0 And prevY <> 0 Then
iDay = (prevY - 1) * 7 + prevX
If iDay Mod 7 <> 0 Then
Me.piccal.DrawLine ((prevX - 1) * DayCellWidth) + 10 + 15, ((prevY - 1) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, ((prevX) * DayCellWidth) - 10 + 15, ((prevY) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, vbWhite, True, True
Me.piccal.ForeColor = vbBlack
Me.piccal.DrawText aDateArray(iDay), (((iDay - 1) Mod 7) * DayCellWidth) + aDayWidth(aDateArray(iDay)) + 15, HeaderMonthH + HeaderDaysH + ((iDay - 1) 7) * DayCellHeight
Else
Me.piccal.DrawLine ((6) * DayCellWidth) + 10 + 15, ((prevY - 2) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, ((7) * DayCellWidth) - 10 + 15, ((prevY - 1) * DayCellHeight) + HeaderMonthH + HeaderDaysH + 10, vbWhite, True, True
Me.piccal.ForeColor = vbBlack
Me.piccal.DrawText aDateArray(iDay), ((6) * DayCellWidth) + aDayWidth(aDateArray(iDay)) + 15, HeaderMonthH + HeaderDaysH + ((iDay - 2) 7) * DayCellHeight
End If
End If
xCell = ((x - 15) DayCellWidth) + 1
yCell = Fix((y - (HeaderMonthH + HeaderDaysH)) DayCellHeight) + 1
' If y > HeaderMonthH + HeaderDaysH Then
iDay = (yCell - 1) * 7 + xCell
If Not IsEmpty(aDateArray(iDay)) Then
DrawReverseDate xCell, yCell, prevX, prevY, iDay
Me.Controls(CallingControl).Text = FormatDateTime(DateSerial(Year(stDate), Month(stDate), aDateArray(iDay)), vbShortDate)
piccal.Visible = False
lstMonthNames.Visible = False
lblMonth.Visible = False
Me.PoLateDay.Text = DateDiff("d", Me.Controls(CallingControl).Text, Date)
End If
End If
End Sub
------------------------------------------------------------------------
If Not IsNull(gobjWork.Fields("PoLateDay").Value) Then
' 이름 설정
' Me.PoLateDay.Text = gobjWork.Fields("PoLateDay").Value
' DateDiff 함수를 이용해서 남은 날을 구한다.
Me.PoLateDay.Text = DateDiff("d", gobjWork.Fields("PoExpire").Value, Date)
End If
위 코드는 일전에 써 넣은 refresh form cd 함수에 있는 부분인데, cdb에서 꺼내온 날짜를 통해 lateday의 변경값을 다시 구한다. 변동적인 값이라, db에 저장하는 것은 의미가 없다. 하지만 field가 만들어져 있으니, 저장시 값으로 저장되어 있고, 그것이 있다면 expire day 기준으로 다시 저장하기 위해 고치는 것이다. 없다면, expire day도 설정이 안 된 것이니(첫번째 함수에 의하여 설정되므로 자동 값이다.) 이 정도는 버그로 치지 않아도 될 것 같다. 그냥 late day를 라벨로 바꿔버려야 겠다.
댓글 달기