Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to set date format in textbox ?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00922980
Message ID:
00923095
Vues:
48
>I got an error with "Cast from string "" to type 'Date' is not valid

The error means that the text in the field is not in the correct format. You may want to try something like below in order to trap for bad input...
        ' Variables
        Dim dInvDate As Date

        ' Trap Errors
        Try

            ' Attemp Convert
            dInvDate = CDate(txtInvoice.Text)

            ' Assign Date
            txtInvoice.Text = Format(dInvDate, "dd-mm-yyyy")

        Catch

            ' Alert User
            txtInvoice.Text = "Invalid Date"

        End Try
Hope that helps...
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform