将控制面板中的日期格式yyyy-mm-dd修改为yyyy/mm/dd格式。
求高手帮忙这么 将控制面板中的日期格式yyyy-mm-dd修改为yyyy/mm/dd格式?? 感激不尽!!最近在网上有看到一段代码如下,但我没有看懂strBuffer = String(lBuffSize, vbNullChar), string明明是一种数据类型, 这么能想函数一样使用,本人新手, 求注解(我是用VB2010 来编写程式的!!)
'--------------------------------------------------------
'Purpose: Change system shortdate format
'Example: Call mdlChangeSystemDateFormat("yyyy/MM/dd")
'--------------------------------------------------------
Public Const LOCALE_SSHORTDATE As Long = &H1F
Public Const LOCALE_USER_DEFAULT As Long = &H400
Public Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal lLocale As Long, ByVal lLocaleType As Long, ByVal sLCData As String, ByVal lBufferLength As Long) As Long
Public Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long
Public Function mdlChangeSystemDateFormat(strFormat As String) As Boolean
Dim strShortDateFormat As String, strBuffer As String
Dim lBuffSize As Long, lRetVal As Long
lBuffSize = 256
strBuffer = String(lBuffSize, vbNullChar)
'Get current short date format
lRetVal = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, strBuffer, lBuffSize)
If lRetVal > 0 Then
strShortDateFormat = Left(strBuffer, lRetVal - 1)
Else
Exit Function
End If
'If current short date format is different from your format, change it.
'Note: MMM should be used in capital for month,small m are for minutes
If UCase(strShortDateFormat) <> UCase(strFormat) Then
lRetVal = SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, strFormat)
End If
If lRetVal > 0 Then mdlChangeSystemDateFormat = True
End Function
补充:VB , 基础类