|
-
Aug 17th, 2006, 09:45 PM
#1
Thread Starter
Hyperactive Member
What country am I in ?
For an application that might be used in any country, is there somehow I can find out the user's country ?
-
Aug 17th, 2006, 10:24 PM
#2
PowerPoster
Re: What country am I in ?
 Originally Posted by RobertLees
For an application that might be used in any country, is there somehow I can find out the user's country ?
the only way you would know is to access their regional and language settings on their computer. unless you coded your app to ask them to specify which country they were in, and then based on that selection do what you need to.
-
Aug 17th, 2006, 11:04 PM
#3
Re: What country am I in ?
Adapt this example from ALLAPI.net:
VB Code:
Const LOCALE_USER_DEFAULT = &H400
Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country
Const LOCALE_SENGLANGUAGE = &H1001 ' English name of language
Const LOCALE_SNATIVELANGNAME = &H4 ' native name of language
Const LOCALE_SNATIVECTRYNAME = &H8 ' native name of country
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 Sub Form_Load()
'KPD-Team 2001
'URL: [url]http://www.allapi.net/[/url]
MsgBox "You live in " & GetInfo(LOCALE_SENGCOUNTRY) & " (" & GetInfo(LOCALE_SNATIVECTRYNAME) & ")," & vbCrLf & "and you speak " & GetInfo(LOCALE_SENGLANGUAGE) & " (" & GetInfo(LOCALE_SNATIVELANGNAME) & ").", vbInformation
End Sub
Public Function GetInfo(ByVal lInfo As Long) As String
Dim Buffer As String, Ret As String
Buffer = String$(256, 0)
Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If Ret > 0 Then
GetInfo = Left$(Buffer, Ret - 1)
Else
GetInfo = ""
End If
End Function
-
Aug 17th, 2006, 11:05 PM
#4
Frenzied Member
Re: What country am I in ?
If they have an internetconnection then you could use their ip adress to determine where they are.
-
Aug 17th, 2006, 11:10 PM
#5
Re: What country am I in ?
If they have an internetconnection then you could use their ip adress to determine where they are.
which is not always right anyway
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 17th, 2006, 11:11 PM
#6
PowerPoster
Re: What country am I in ?
 Originally Posted by westconn1
which is not always right anyway
true
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|