dcsimg
Results 1 to 7 of 7

Thread: DateTimePicker Language and settings are changing!!

  1. #1

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    DateTimePicker Language and settings are changing!!

    I have a DateTimePicker tool on my project form and it's all fine on my PC, but when trying to test it on other machines it's language and settings changes according to the PC running the program.

    how to make sure it will be all the time English and Gregorian and will never be changed according to the PC language and calendar?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,722

    Re: DateTimePicker Language and settings are changing!!

    Aaaah..... you don't. You respect the user's settings. Or you build your own control that completely ignores the user's settings and does its own thing.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,357

    Re: DateTimePicker Language and settings are changing!!

    Letting it change as it does means that the user gets to see it in a way that is natural for them, so they will be comfortable with it - probably more comfortable than with what you want.

    It doesn't need to a affect your code in any way (as long as you are using the .Value property rather than .Text), so is there really a reason to try to force it to be different?

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,124

    Re: DateTimePicker Language and settings are changing!!

    As si suggests, if you find that a user's system settings are affecting your code then the issue is probably with your code. Can you show us how you're using this DateTimePicker and explain how that's being affected by system settings?

  5. #5

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Re: DateTimePicker Language and settings are changing!!

    Quote Originally Posted by techgnome View Post
    Aaaah..... you don't. You respect the user's settings. Or you build your own control that completely ignores the user's settings and does its own thing.

    -tg
    Quote Originally Posted by si_the_geek View Post
    Letting it change as it does means that the user gets to see it in a way that is natural for them, so they will be comfortable with it - probably more comfortable than with what you want.

    It doesn't need to a affect your code in any way (as long as you are using the .Value property rather than .Text), so is there really a reason to try to force it to be different?
    Quote Originally Posted by jmcilhinney View Post
    As si suggests, if you find that a user's system settings are affecting your code then the issue is probably with your code. Can you show us how you're using this DateTimePicker and explain how that's being affected by system settings?


    Well,there is a good reason for that. Actually the program takes the (.Text) of the DateTimePicker and transfers it to an Excel sheet where there is an OFFICIAL form and the Date must be in English and Gregorian and there is a calculation for the Julian date too.

    So I don't want to effect the user's settings but I want it to be in the official form to be printed as he/she sure wants it to be.

    I think here is what I should do

    Quote Originally Posted by si_the_geek View Post
    It doesn't need to a affect your code in any way (as long as you are using the .Value property rather than .Text)
    and here is the code i'm using with it:

    Code:
    With xlWorkSheet
                '~~> Directly type the values that we want
                .Range("B1").Value = ComboBox6.Text
                .Range("B7").Value = DateTimePicker1.Text
                .Range("B8").Value = DateTimePicker2.Text + "   " + JDateN.Text
                .Range("F8").Value = "PAGE " + ComboBox8.Text
                .Range("j34").Value = SHOP_OFFICERTextBox.Text
                .Range("y34").Value = SHOP_HEADTextBox.Text
                .Range("E39").Value = PRODUCTION_OFFICERTextBox.Text
                .Range("M39").Value = MANAGERTextBox.Text
                .Range("X39").Value = DIRECTOR_SRFTextBox.Text
            End With
    So is it only the matter off taking the the value rather than the text?

  6. #6

    Thread Starter
    Hyperactive Member Joye's Avatar
    Join Date
    Jul 2009
    Posts
    256

    Re: DateTimePicker Language and settings are changing!!

    Some of the sittings
    Name:  OT.jpg
Views: 24
Size:  40.7 KB

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,124

    Re: DateTimePicker Language and settings are changing!!

    Quote Originally Posted by Joye View Post
    Well,there is a good reason for that. Actually the program takes the (.Text) of the DateTimePicker and transfers it to an Excel sheet
    And that's where your code is worng.
    Quote Originally Posted by Joye View Post
    So is it only the matter off taking the the value rather than the text?
    Yes. The Value property is type DateTime so it is unaffected by format. You should pretty much NEVER use the Text property of a DateTimePicker. If you want to set the date/time then you assign a DateTime to the Value property. How you get that DateTime is up to you. If you want to get the date/time entered by the user then you get a DateTime from the Value property. Every user should see what they expect to see in the control and be able to set it as they expect to set it. For instance, if I was to look at a DateTimePicker that contained the date for January 10, 2018 here in Australia then I should see "10/01/2018" while a person in America should see "1/10/2018". It's the same date in both cases but we each see what we expect to see. ALWAYS work with the Value property.

    Once you have a DateTime, you can do what you want with it and what you do is nothing to do with the DateTimePicker. If you're working in a context that doesn't have a dedicated date data type, e.g. Excel, and you have to use text then it's a good idea to use an unambiguous format, e.g. "yyyy-MM-dd". That's how you normally represent dates in SQL Server Management Studio when writing SQL code, for instance. You can convert a DateTime to a String in whatever format you want by calling its ToString method and passing the appropriate format specifier. Again, that step has nothing to do with the DateTimePicker.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width