Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Anyone know how to convert string to datetime in vb.net
Message
 
À
28/03/2011 12:11:15
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows XP
Database:
Jet/Access Engine
Divers
Thread ID:
01505223
Message ID:
01505252
Vues:
59
>Hi, all
> i want to string to datatime in vb.net , anyone know?
> if the current time ,i know, but if people entry, how can i do......
> And i need converted and use isdate to check........ thx
>
>
>
> Maskedate.Text = Convert.ToDateTime(Now).ToString("dd/MM/yyyy")
>
>
C#
   string entered = "01/11/2011";
   DateTime dateEntered;
   DateTime.TryParse(entered, out dateEntered);
VB.NET
Dim entered As String = "01/11/2011"
Dim dateEntered As DateTime
DateTime.TryParse(entered, dateEntered)
Actually, you will probably want to use the TryParseExact. You'll need to adjust the CultureInfo string, and possibly DateTimeStyles.
Dim entered As String = "01/11/2011"
Dim dateEntered As DateTime
DateTime.TryParseExact(entered, "dd/MM/yyyy", new CultureInfo("en-us"), DateTimeStyles.None, dateEntered)
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform