Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Windows Regional Settings with VB6

Status
Not open for further replies.

OOzy

Programmer
Jul 24, 2000
135
SA
How can change the Windows' Regional Setting using VB6. I would like to change the Date format from mm/dd/yy to dd/mm/yy.

 
The following API code will get/set the short date from Vb.

Code:
Option Explicit

Private Declare Function GetUserDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Declare Function SetLocaleInfo Lib "kernel32" Alias "SetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String) As Long
Const LOCALE_SSHORTDATE = &H1F

Public Function GetShortDate() As String
   Dim sLen    As Long
   Dim sDate   As String * 32

   sLen = GetLocaleInfo(GetUserDefaultLCID(), LOCALE_SSHORTDATE, sDate, 64)
   GetShortDate = Left$(sDate, sLen - 1)
End Function

Public Function SetShortDate(NewFormat As String) As String
   SetLocaleInfo GetUserDefaultLCID(), LOCALE_SSHORTDATE, NewFormat
End Function

Private Sub Form_Load()
   MsgBox "ShortDateFormat is " & GetShortDate
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top