Date: 02-16-2022
Return to Index
created by gbSnippets
'For sorting purposes, it's more useful when the year is listed first.
'Primary code:
'Uses the Parse$ function to change the order of MM-DD-YYYY format that
'is returned by the PowerBASIC Date$ function
Function YearFirst(DT) As String
'DT must be MM-DD-YYYY
Function = Parse$(DT,"-",3) + Parse$(DT,"-",1) + Parse$(DT,"-",2)
End Function
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg as Dword
%IDC_Button = 100
Function PBMain() As Long
Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button,"Push", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
If CB.Msg = %WM_Command AND CB.Ctl = %IDC_Button AND CB.Ctlmsg = %BN_Clicked Then
MsgBox YearFirst(Date$)
End If
End Function
Function YearFirst(DT As String) As String
'DT must be MM-DD-YYYY
Function = Parse$(DT,"-",3) + "-" + Parse$(DT,"-",1) + "-" + Parse$(DT,"-",2)
End Function
'gbs_00258
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm