|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
changing the date format in vb.netWhen I copy a vb.net project using date formats from one PC with a windows
date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response instead of using or changing the date, why not make your own?
Dim str as String = Now.Day & "/" & Now.Month & "/" & Now.Year which gives: dd/mm/yy -- -iwdu15 That don't work
When i put in dd/mm/yy in my vb/.net program (on the other PC) is thinking that is is yy/mm/dd so there is a error There is some code for it with the word globalisation but I don't know the code Thanks any way Show quoteHide quote "iwdu15" <jmmgoalsteratyahoodotcom> wrote in message news:17E82E44-F26D-46B8-ABD2-7850C11B061D@microsoft.com... > instead of using or changing the date, why not make your own? > > Dim str as String = Now.Day & "/" & Now.Month & "/" & Now.Year > > which gives: > > dd/mm/yy > > -- > -iwdu15 Andreas,
Strange, I can assure you that Ken and I exhange programs on regular base. He is in the US and I in the EU. We never had any problem with datetime. That would be crazy because in datetime there is not in a special culture. It is a "long" which holds a counter of 100 nanoseconds ticks that started (in Net) at the Christian calendar date 01/01/01 00:00:00. In other systems the starting time and way it is done can be different. But never try to convert the datetime to string formats with another reasons than to show those. I hope this helps, Cor Show quoteHide quote "andreas" <andr***@pandora.be> schreef in bericht news:Od_jg.482293$Kh.12205161@phobos.telenet-ops.be... > When I copy a vb.net project using date formats from one PC with a windows > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I > get errors. > How can I change for a while in the project the date format in vb.code ( > not in Windows) and how can I find out which date format the PC Windows is > using. > Thanks for any response > > > When the date format is changed in windows (configuration panel) i got a
error on a different PC and on my own PC the dates with month = 25,13,.. and so on where not listened. It depens likely on the settings mm/dd/yyyy or yyy/mm/dd. And that is my question for a solution in vb.net to detect and to change these PC settings Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:OebkcGEkGHA.4044@TK2MSFTNGP03.phx.gbl... > Andreas, > > Strange, I can assure you that Ken and I exhange programs on regular base. > > He is in the US and I in the EU. We never had any problem with datetime. > > That would be crazy because in datetime there is not in a special culture. > It is a "long" which holds a counter of 100 nanoseconds ticks that started > (in Net) at the Christian calendar date 01/01/01 00:00:00. In other systems > the starting time and way it is done can be different. > > But never try to convert the datetime to string formats with another reasons > than to show those. > > I hope this helps, > > Cor > > > "andreas" <andr***@pandora.be> schreef in bericht > news:Od_jg.482293$Kh.12205161@phobos.telenet-ops.be... > > When I copy a vb.net project using date formats from one PC with a windows > > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I > > get errors. > > How can I change for a while in the project the date format in vb.code ( > > not in Windows) and how can I find out which date format the PC Windows is > > using. > > Thanks for any response > > > > > > > > Andreas,
Did you set a string to a datetime somewhere? By instance a command like dim a as date = CDate(25/06/2006)" or the same with DateTime.parse or with DateTime.Convert or with CType("date",datetime) Cor Show quoteHide quote "andreas" <andr***@pandora.be> schreef in bericht news:uFakg.483254$t42.12494959@phobos.telenet-ops.be... > When the date format is changed in windows (configuration panel) i got a > error on a different PC and on my own PC the dates with month = 25,13,.. > and so on where not listened. > It depens likely on the settings mm/dd/yyyy or yyy/mm/dd. > And that is my question for a solution in vb.net to detect and to change > these PC settings > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:OebkcGEkGHA.4044@TK2MSFTNGP03.phx.gbl... >> Andreas, >> >> Strange, I can assure you that Ken and I exhange programs on regular >> base. >> >> He is in the US and I in the EU. We never had any problem with datetime. >> >> That would be crazy because in datetime there is not in a special >> culture. >> It is a "long" which holds a counter of 100 nanoseconds ticks that >> started >> (in Net) at the Christian calendar date 01/01/01 00:00:00. In other > systems >> the starting time and way it is done can be different. >> >> But never try to convert the datetime to string formats with another > reasons >> than to show those. >> >> I hope this helps, >> >> Cor >> >> >> "andreas" <andr***@pandora.be> schreef in bericht >> news:Od_jg.482293$Kh.12205161@phobos.telenet-ops.be... >> > When I copy a vb.net project using date formats from one PC with a > windows >> > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then > I >> > get errors. >> > How can I change for a while in the project the date format in vb.code > ( >> > not in Windows) and how can I find out which date format the PC Windows > is >> > using. >> > Thanks for any response >> > >> > >> > >> >> > > Yes
I have to read a textdate from a textfile into a textbox and I would'n change my textfile. I put it again, I like to change the windows date format with a command in my vb.net program so that I can run my program on any PC. Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:eq$Pe#HkGHA.1264@TK2MSFTNGP05.phx.gbl... > Andreas, > > Did you set a string to a datetime somewhere? > > By instance a command like > dim a as date = CDate(25/06/2006)" > or the same with > DateTime.parse > or with > DateTime.Convert > or with > CType("date",datetime) > > Cor > > "andreas" <andr***@pandora.be> schreef in bericht > news:uFakg.483254$t42.12494959@phobos.telenet-ops.be... > > When the date format is changed in windows (configuration panel) i got a > > error on a different PC and on my own PC the dates with month = 25,13,.. > > and so on where not listened. > > It depens likely on the settings mm/dd/yyyy or yyy/mm/dd. > > And that is my question for a solution in vb.net to detect and to change > > these PC settings > > > > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > > news:OebkcGEkGHA.4044@TK2MSFTNGP03.phx.gbl... > >> Andreas, > >> > >> Strange, I can assure you that Ken and I exhange programs on regular > >> base. > >> > >> He is in the US and I in the EU. We never had any problem with datetime. > >> > >> That would be crazy because in datetime there is not in a special > >> culture. > >> It is a "long" which holds a counter of 100 nanoseconds ticks that > >> started > >> (in Net) at the Christian calendar date 01/01/01 00:00:00. In other > > systems > >> the starting time and way it is done can be different. > >> > >> But never try to convert the datetime to string formats with another > > reasons > >> than to show those. > >> > >> I hope this helps, > >> > >> Cor > >> > >> > >> "andreas" <andr***@pandora.be> schreef in bericht > >> news:Od_jg.482293$Kh.12205161@phobos.telenet-ops.be... > >> > When I copy a vb.net project using date formats from one PC with a > > windows > >> > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then > > I > >> > get errors. > >> > How can I change for a while in the project the date format in vb.code > > ( > >> > not in Windows) and how can I find out which date format the PC Windows > > is > >> > using. > >> > Thanks for any response > >> > > >> > > >> > > >> > >> > > > > > > Andreas,
Than you have to know the format how that date is written and use the overloaded command. datetime.parseexact http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclassparseexacttopic1.asp If you are sure that the dates are only in numbers than the last operand can be nothing. Be aware that this is only in the case of by instand textfiles to datetime. In another culture will the user in the UI type the date in the style he is used to, therefore from a textbox a CDate works perfect. I hope this hels, Cor Show quoteHide quote "andreas" <andr***@pandora.be> schreef in bericht news:Vlhkg.483801$Pj5.12470332@phobos.telenet-ops.be... > Yes > I have to read a textdate from a textfile into a textbox and I would'n > change my textfile. > I put it again, I like to change the windows date format with a command in > my vb.net program so that I can run my program on any PC. > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:eq$Pe#HkGHA.1264@TK2MSFTNGP05.phx.gbl... >> Andreas, >> >> Did you set a string to a datetime somewhere? >> >> By instance a command like >> dim a as date = CDate(25/06/2006)" >> or the same with >> DateTime.parse >> or with >> DateTime.Convert >> or with >> CType("date",datetime) >> >> Cor >> >> "andreas" <andr***@pandora.be> schreef in bericht >> news:uFakg.483254$t42.12494959@phobos.telenet-ops.be... >> > When the date format is changed in windows (configuration panel) i got >> > a >> > error on a different PC and on my own PC the dates with month = >> > 25,13,.. >> > and so on where not listened. >> > It depens likely on the settings mm/dd/yyyy or yyy/mm/dd. >> > And that is my question for a solution in vb.net to detect and to >> > change >> > these PC settings >> > >> > >> > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message >> > news:OebkcGEkGHA.4044@TK2MSFTNGP03.phx.gbl... >> >> Andreas, >> >> >> >> Strange, I can assure you that Ken and I exhange programs on regular >> >> base. >> >> >> >> He is in the US and I in the EU. We never had any problem with > datetime. >> >> >> >> That would be crazy because in datetime there is not in a special >> >> culture. >> >> It is a "long" which holds a counter of 100 nanoseconds ticks that >> >> started >> >> (in Net) at the Christian calendar date 01/01/01 00:00:00. In other >> > systems >> >> the starting time and way it is done can be different. >> >> >> >> But never try to convert the datetime to string formats with another >> > reasons >> >> than to show those. >> >> >> >> I hope this helps, >> >> >> >> Cor >> >> >> >> >> >> "andreas" <andr***@pandora.be> schreef in bericht >> >> news:Od_jg.482293$Kh.12205161@phobos.telenet-ops.be... >> >> > When I copy a vb.net project using date formats from one PC with a >> > windows >> >> > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd > then >> > I >> >> > get errors. >> >> > How can I change for a while in the project the date format in > vb.code >> > ( >> >> > not in Windows) and how can I find out which date format the PC > Windows >> > is >> >> > using. >> >> > Thanks for any response >> >> > >> >> > >> >> > >> >> >> >> >> > >> > >> >> > > "andreas" <andr***@pandora.be> schrieb: 'System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat'.> When I copy a vb.net project using date formats from one PC with a windows > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I > get errors. > How can I change for a while in the project the date format in vb.code ( > not in Windows) and how can I find out which date format the PC Windows is > using. Using a culture-specific date/time format to persist dates is never a good idea if data is exchanged between machines which are potentially running with different date/time formats. Instead, use 'CultureInfo.InvariantCulture.DateTimeFormat' to format the dates when persisting them and use the invariant culture to read the date values later on. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
The invarianculture in case of datetime is associated with the English Language where you can have dependend of the culture june 15 and 15 june. This makes it possible to do a dataparse.time(date in written words) for both culture systems in the English language. Dates written in German needs the parameter in that case that it is in the German culture, however if that is the local setting than Nothing is more than enough (while invariantculture will than have the same effect as nothing because the culture is already German). The last is probably your situation. The system does not automaticly recognise that by instance "1/12/2006" is one time 12 december and anoter time januari 12 how much time you write that it is an invariant culture. Cor Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:%23rfMmHHkGHA.4776@TK2MSFTNGP05.phx.gbl... > "andreas" <andr***@pandora.be> schrieb: >> When I copy a vb.net project using date formats from one PC with a >> windows >> date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I >> get errors. >> How can I change for a while in the project the date format in vb.code ( >> not in Windows) and how can I find out which date format the PC Windows >> is >> using. > > 'System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat'. > > Using a culture-specific date/time format to persist dates is never a good > idea if data is exchanged between machines which are potentially running > with different date/time formats. Instead, use > 'CultureInfo.InvariantCulture.DateTimeFormat' to format the dates when > persisting them and use the invariant culture to read the date values > later on. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: The invariant culture is invariant by definition and it's unique, which > The invarianculture in case of datetime is associated with the English > Language where you can have dependend of the culture june 15 and 15 june. means that it doesn't suffer from the problems other cultures suffer from. If June, 15th is persisted using the invariant culture and later read using the invariant culture, it will always result in June, 15th. > This makes it possible to do a dataparse.time(date in written words) for Why would you want to mix up different cultures? > both culture systems in the English language. 'CultureInfo.InvariantCulture' has (by definition) as much to do with 'de' as with 'en'. It's simply a separate culture. > Dates written in German needs the parameter in that case that it is in the ?!? 'InvariantCulture' is a completely independent culture. It has the > German culture, however if that is the local setting than Nothing is more > than enough (while invariantculture will than have the same effect as > nothing because the culture is already German). same semantics on all systems and thus will never be the same as another culture. > The system does not automaticly recognise that by instance "1/12/2006" is If you have a 'Date' variable representing '#1/12/2006#' (written as VB date > one time 12 december and anoter time januari 12 how much time you write > that it is an invariant culture. literal) and persist it using the invariant culture and later use the invariant culture to read the persisted value the resulting 'Date' object will have the value '#1/12/2006#'. One doesn't have to care about and know the format used to persist the date using the invariant culture. The invariant culture's main purpose is to make exchange of data between different systems running with different culture settings easier by removing any ambiguities potentially caused by different culture settings. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
What does this text in the description page of DateTime mean for you. Each DateTime member implicitly uses the Gregorian calendar to perform its operation, with the exception of constructors that specify a calendar and methods that implicitly specify a calendar with a parameter derived from IFormatProvider, such as System.Globalization.DateTimeFormatInfo. Use the System.Globalization.Calendar class to perform date and time operations with a different calendar. *methods* that implicitly specify a calendar etc. The description from the datetime is: The DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) to 11:59:59 P.M., December 31, 9999 A.D. (C.E.) Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 1 A.D. (C.E.) in the GregorianCalendar calendar. For example, a ticks value of 31241376000000000L represents the date, Friday, January 01, 0100 12:00:00 midnight. A DateTime value is always expressed in the context of an explicit or default calendar. As I read it as you write, than you give me the idea that for you a datetime is stored in the way as in the literals. The dateobject does not have the value '#1/12/2006#' it has just a counter which has a starting point at 01/01/00 00:00:00 in our notation in ISO. I could not find any member for a stored DateTimeFormatInfo inside the DateTime structure Cor Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:e220YJIkGHA.4660@TK2MSFTNGP05.phx.gbl... > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: >> The invarianculture in case of datetime is associated with the English >> Language where you can have dependend of the culture june 15 and 15 june. > > The invariant culture is invariant by definition and it's unique, which > means that it doesn't suffer from the problems other cultures suffer from. > If June, 15th is persisted using the invariant culture and later read > using the invariant culture, it will always result in June, 15th. > >> This makes it possible to do a dataparse.time(date in written words) for >> both culture systems in the English language. > > Why would you want to mix up different cultures? > 'CultureInfo.InvariantCulture' has (by definition) as much to do with 'de' > as with 'en'. It's simply a separate culture. > >> Dates written in German needs the parameter in that case that it is in >> the German culture, however if that is the local setting than Nothing is >> more than enough (while invariantculture will than have the same effect >> as nothing because the culture is already German). > > ?!? 'InvariantCulture' is a completely independent culture. It has the > same semantics on all systems and thus will never be the same as another > culture. > >> The system does not automaticly recognise that by instance "1/12/2006" is >> one time 12 december and anoter time januari 12 how much time you write >> that it is an invariant culture. > > If you have a 'Date' variable representing '#1/12/2006#' (written as VB > date literal) and persist it using the invariant culture and later use the > invariant culture to read the persisted value the resulting 'Date' object > will have the value '#1/12/2006#'. One doesn't have to care about and > know the format used to persist the date using the invariant culture. The > invariant culture's main purpose is to make exchange of data between > different systems running with different culture settings easier by > removing any ambiguities potentially caused by different culture settings. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Nobody's claiming that. 'DateTime' per-se doesn't have to do anything with > I could not find any member for a stored DateTimeFormatInfo inside the > DateTime structure a specific culture. Cultures come into the play when formatting the date to persist it, for example. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried and Cor,
Thanks, it is very interesting but I want ( if possible) a direct answer. When can change in Windows - Control panel the format of the date and it is important for vb.net when reading a date in plain tekst in a textfile When the windows format is f.e. yyyy/mm/dd and the textfile gives in plain tekst 31/12/2005 then I get a error. When I change the windows format in dd/mm/yyyy than the date is reading. Is it possible and how can I : Dedect in VB.net what the setting is in O.S. Change this setting in what I want in vb.net at the beginning of the program. Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:#rfMmHHkGHA.4776@TK2MSFTNGP05.phx.gbl... > "andreas" <andr***@pandora.be> schrieb: > > When I copy a vb.net project using date formats from one PC with a windows > > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I > > get errors. > > How can I change for a while in the project the date format in vb.code ( > > not in Windows) and how can I find out which date format the PC Windows is > > using. > > 'System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat'. > > Using a culture-specific date/time format to persist dates is never a good > idea if data is exchanged between machines which are potentially running > with different date/time formats. Instead, use > 'CultureInfo.InvariantCulture.DateTimeFormat' to format the dates when > persisting them and use the invariant culture to read the date values later > on. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > Andreas,
Newsgroups are meant as a communitiy, where problems can be discussed in any way by the contributers who want to learn from each other. If you want only a direct answer to your questions, than you can better go to a paid Microsoft Support Center or hire in another way an advisor. Just my thought, Cor Show quoteHide quote "andreas" <andr***@pandora.be> schreef in bericht news:0Sqkg.484528$u41.12588151@phobos.telenet-ops.be... > Herfried and Cor, > Thanks, it is very interesting but I want ( if possible) a direct answer. > > When can change in Windows - Control panel the format of the date and it > is > important for vb.net when reading a date in plain tekst in a textfile > When the windows format is f.e. yyyy/mm/dd and the textfile gives in plain > tekst 31/12/2005 then I get a error. > When I change the windows format in dd/mm/yyyy than the date is reading. > Is it possible and how can I : > Dedect in VB.net what the setting is in O.S. > Change this setting in what I want in vb.net at the beginning of the > program. > > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > news:#rfMmHHkGHA.4776@TK2MSFTNGP05.phx.gbl... >> "andreas" <andr***@pandora.be> schrieb: >> > When I copy a vb.net project using date formats from one PC with a > windows >> > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then > I >> > get errors. >> > How can I change for a while in the project the date format in vb.code > ( >> > not in Windows) and how can I find out which date format the PC Windows > is >> > using. >> >> 'System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat'. >> >> Using a culture-specific date/time format to persist dates is never a >> good >> idea if data is exchanged between machines which are potentially running >> with different date/time formats. Instead, use >> 'CultureInfo.InvariantCulture.DateTimeFormat' to format the dates when >> persisting them and use the invariant culture to read the date values > later >> on. >> >> -- >> M S Herfried K. Wagner >> M V P <URL:http://dotnet.mvps.org/> >> V B <URL:http://classicvb.org/petition/> >> > > Cor,
There is a misunderstanding. I don't need a personal message but in the newsgroup codelines who are a solution for my questions. I see now a answer from herfried which I will try (if I can) Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:eAG9AUQkGHA.1276@TK2MSFTNGP03.phx.gbl... > Andreas, > > Newsgroups are meant as a communitiy, where problems can be discussed in any > way by the contributers who want to learn from each other. > > If you want only a direct answer to your questions, than you can better go > to a paid Microsoft Support Center or hire in another way an advisor. > > Just my thought, > > Cor > > "andreas" <andr***@pandora.be> schreef in bericht > news:0Sqkg.484528$u41.12588151@phobos.telenet-ops.be... > > Herfried and Cor, > > Thanks, it is very interesting but I want ( if possible) a direct answer. > > > > When can change in Windows - Control panel the format of the date and it > > is > > important for vb.net when reading a date in plain tekst in a textfile > > When the windows format is f.e. yyyy/mm/dd and the textfile gives in plain > > tekst 31/12/2005 then I get a error. > > When I change the windows format in dd/mm/yyyy than the date is reading. > > Is it possible and how can I : > > Dedect in VB.net what the setting is in O.S. > > Change this setting in what I want in vb.net at the beginning of the > > program. > > > > > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message > > news:#rfMmHHkGHA.4776@TK2MSFTNGP05.phx.gbl... > >> "andreas" <andr***@pandora.be> schrieb: > >> > When I copy a vb.net project using date formats from one PC with a > > windows > >> > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then > > I > >> > get errors. > >> > How can I change for a while in the project the date format in vb.code > > ( > >> > not in Windows) and how can I find out which date format the PC Windows > > is > >> > using. > >> > >> 'System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat'. > >> > >> Using a culture-specific date/time format to persist dates is never a > >> good > >> idea if data is exchanged between machines which are potentially running > >> with different date/time formats. Instead, use > >> 'CultureInfo.InvariantCulture.DateTimeFormat' to format the dates when > >> persisting them and use the invariant culture to read the date values > > later > >> on. > >> > >> -- > >> M S Herfried K. Wagner > >> M V P <URL:http://dotnet.mvps.org/> > >> V B <URL:http://classicvb.org/petition/> > >> > > > > > > Andreas,
I would just use the parseexact as I have showed you in another message and if you speak Dutch than you can try to get the Benelux Dutch language .Net magazine from march. I have written a complete article about more than your question alone in that about all kind of situations with DateTime (for C# and VBNet). Cor Show quoteHide quote "andreas" <andr***@pandora.be> schreef in bericht news:FMwkg.484982$t61.12592256@phobos.telenet-ops.be... > Cor, > There is a misunderstanding. > I don't need a personal message but in the newsgroup codelines who are a > solution for my questions. > I see now a answer from herfried which I will try (if I can) > > > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:eAG9AUQkGHA.1276@TK2MSFTNGP03.phx.gbl... >> Andreas, >> >> Newsgroups are meant as a communitiy, where problems can be discussed in > any >> way by the contributers who want to learn from each other. >> >> If you want only a direct answer to your questions, than you can better > go >> to a paid Microsoft Support Center or hire in another way an advisor. >> >> Just my thought, >> >> Cor >> >> "andreas" <andr***@pandora.be> schreef in bericht >> news:0Sqkg.484528$u41.12588151@phobos.telenet-ops.be... >> > Herfried and Cor, >> > Thanks, it is very interesting but I want ( if possible) a direct > answer. >> > >> > When can change in Windows - Control panel the format of the date and >> > it >> > is >> > important for vb.net when reading a date in plain tekst in a textfile >> > When the windows format is f.e. yyyy/mm/dd and the textfile gives in > plain >> > tekst 31/12/2005 then I get a error. >> > When I change the windows format in dd/mm/yyyy than the date is >> > reading. >> > Is it possible and how can I : >> > Dedect in VB.net what the setting is in O.S. >> > Change this setting in what I want in vb.net at the beginning of the >> > program. >> > >> > >> > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message >> > news:#rfMmHHkGHA.4776@TK2MSFTNGP05.phx.gbl... >> >> "andreas" <andr***@pandora.be> schrieb: >> >> > When I copy a vb.net project using date formats from one PC with a >> > windows >> >> > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd > then >> > I >> >> > get errors. >> >> > How can I change for a while in the project the date format in > vb.code >> > ( >> >> > not in Windows) and how can I find out which date format the PC > Windows >> > is >> >> > using. >> >> >> >> 'System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat'. >> >> >> >> Using a culture-specific date/time format to persist dates is never a >> >> good >> >> idea if data is exchanged between machines which are potentially > running >> >> with different date/time formats. Instead, use >> >> 'CultureInfo.InvariantCulture.DateTimeFormat' to format the dates when >> >> persisting them and use the invariant culture to read the date values >> > later >> >> on. >> >> >> >> -- >> >> M S Herfried K. Wagner >> >> M V P <URL:http://dotnet.mvps.org/> >> >> V B <URL:http://classicvb.org/petition/> >> >> >> > >> > >> >> > > "andreas" <andr***@pandora.be> schrieb: You don't need to worry about the OS settings. Just set the application's > When can change in Windows - Control panel the format of the date and it > is > important for vb.net when reading a date in plain tekst in a textfile > When the windows format is f.e. yyyy/mm/dd and the textfile gives in plain > tekst 31/12/2005 then I get a error. > When I change the windows format in dd/mm/yyyy than the date is reading. > Is it possible and how can I : > Dedect in VB.net what the setting is in O.S. 'CurrentCulture' to the culture you want to use to persist the data and then reset it to its previous value. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
Thanks and I will try your solution. Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:#i6Pl8SkGHA.4776@TK2MSFTNGP05.phx.gbl... > "andreas" <andr***@pandora.be> schrieb: > > When can change in Windows - Control panel the format of the date and it > > is > > important for vb.net when reading a date in plain tekst in a textfile > > When the windows format is f.e. yyyy/mm/dd and the textfile gives in plain > > tekst 31/12/2005 then I get a error. > > When I change the windows format in dd/mm/yyyy than the date is reading. > > Is it possible and how can I : > > Dedect in VB.net what the setting is in O.S. > > You don't need to worry about the OS settings. Just set the application's > 'CurrentCulture' to the culture you want to use to persist the data and then > reset it to its previous value. > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> > Hi, Andreas:
To retrieve the date format for the current user use this: Dim tdfi As New System.Globalization.DateTimeFormatInfo Dim dtFormat As String = tdfi.CurrentInfo.ShortDatePattern dtFormat then contains the string you're looking for (e.g. "dd.MM.yyyy"). This is the format of the user settings for the account the program is running under. So this might only help you to write the format into a file, but not to recognize the format in the file. But I wonder, if you receive the file with those data, don't you know the date format? If not, you might want to ask the person who sends you the file to include an .INI file with the date format or to write the date format into the first line of the file. If you know the date format you can process it like this: Dim FlatFileDate As String, DisplayDate As String Dim tMonth As Integer, tDay As Integer, tYear As Integer FlatFileDate = "06252006" '=MMDDYYYY, that's what you read from your ' file 'Lets say you want to convert to YYYYMMDD tMonth = Val(Strings.Left(FlatFileDate, 2)) tDay = Val(Strings.Mid(FlatFileDate, 3, 2)) tYear = Val(Strings.Right(FlatFileDate, 4)) Dim dt As New Date(tYear, tMonth, tDay) 'Creates a date variable with 'the date you just processed. DisplayDate = Format(dt, "Short Date") 'Formats the date to local short 'date MsgBox(DisplayDate) Best Regards, HKSHK andreas wrote: Show quoteHide quote > When I copy a vb.net project using date formats from one PC with a windows > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I > get errors. > How can I change for a while in the project the date format in vb.code ( > not in Windows) and how can I find out which date format the PC Windows is > using. > Thanks for any response > > > Thanks very much HKSHK ! (and all the others to)
This is the best answer I recieved to my questions! Thanks a lot again Show quoteHide quote "HKSHK" <hk***@gmx.net> wrote in message news:e6tvcc$f7s$1@news.datemas.de... > Hi, Andreas: > > To retrieve the date format for the current user use this: > Dim tdfi As New System.Globalization.DateTimeFormatInfo > Dim dtFormat As String = tdfi.CurrentInfo.ShortDatePattern > > dtFormat then contains the string you're looking for > (e.g. "dd.MM.yyyy"). This is the format of the user settings for the > account the program is running under. So this might only help you to > write the format into a file, but not to recognize the format in the file. > > But I wonder, if you receive the file with those data, don't you know > the date format? If not, you might want to ask the person who sends you > the file to include an .INI file with the date format or to write the > date format into the first line of the file. If you know the date format > you can process it like this: > > Dim FlatFileDate As String, DisplayDate As String > Dim tMonth As Integer, tDay As Integer, tYear As Integer > > FlatFileDate = "06252006" '=MMDDYYYY, that's what you read from your > ' file > > 'Lets say you want to convert to YYYYMMDD > > tMonth = Val(Strings.Left(FlatFileDate, 2)) > tDay = Val(Strings.Mid(FlatFileDate, 3, 2)) > tYear = Val(Strings.Right(FlatFileDate, 4)) > > Dim dt As New Date(tYear, tMonth, tDay) 'Creates a date variable with > 'the date you just processed. > > DisplayDate = Format(dt, "Short Date") 'Formats the date to local short > 'date > > MsgBox(DisplayDate) > > Best Regards, > > HKSHK > > andreas wrote: > > When I copy a vb.net project using date formats from one PC with a windows > > date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I > > get errors. > > How can I change for a while in the project the date format in vb.code ( > > not in Windows) and how can I find out which date format the PC Windows is > > using. > > Thanks for any response > > > > > >
Datasets - use 1 or many?
Assigning the result of a '/' division to an integer type causes rounding last ditch attempt to try and get this working error in the update Streamreader doesn't read the line properly identity /autonumber drives me nuts From Delphi to VB WithEvents code in module cannot change textbox on main form Reading XML file getting error Complementary colors? |
|||||||||||||||||||||||