Results 1 to 6 of 6

Thread: What country am I in ?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Wellington, NZ
    Posts
    267

    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 ?

  2. #2
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: What country am I in ?

    Quote 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.

  3. #3
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: What country am I in ?

    Adapt this example from ALLAPI.net:
    VB Code:
    1. Const LOCALE_USER_DEFAULT = &H400
    2. Const LOCALE_SENGCOUNTRY = &H1002 ' English name of country
    3. Const LOCALE_SENGLANGUAGE = &H1001  ' English name of language
    4. Const LOCALE_SNATIVELANGNAME = &H4  ' native name of language
    5. Const LOCALE_SNATIVECTRYNAME = &H8  ' native name of country
    6. 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
    7. Private Sub Form_Load()
    8.     'KPD-Team 2001
    9.     'URL: [url]http://www.allapi.net/[/url]
    10.     'E-Mail: [email][email protected][/email]
    11.     MsgBox "You live in " & GetInfo(LOCALE_SENGCOUNTRY) & " (" & GetInfo(LOCALE_SNATIVECTRYNAME) & ")," & vbCrLf & "and you speak " & GetInfo(LOCALE_SENGLANGUAGE) & " (" & GetInfo(LOCALE_SNATIVELANGNAME) & ").", vbInformation
    12. End Sub
    13. Public Function GetInfo(ByVal lInfo As Long) As String
    14.     Dim Buffer As String, Ret As String
    15.     Buffer = String$(256, 0)
    16.     Ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
    17.     If Ret > 0 Then
    18.         GetInfo = Left$(Buffer, Ret - 1)
    19.     Else
    20.         GetInfo = ""
    21.     End If
    22. End Function

  4. #4
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: What country am I in ?

    If they have an internetconnection then you could use their ip adress to determine where they are.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  6. #6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width