Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set date format in textbox ?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00922980
Message ID:
00923095
Views:
49
>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...
Previous
Reply
Map
View

Click here to load this message in the networking platform