By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

String Convert to Date Time Problem is Windows 98

P: n/a
I use the vb.net make the program that save the date and any Information
field.
when I input the date in textbox then I save to database occurs error that
is
"Cast from string "20/08/2003" to type 'Date' is not valid.
I use this command change string to Date
dim year as date
dim strYear as string
=> year = ctype(stryear,Date).ADDYEAR(2)
I only in Windows 98 have problem
but In windows XP is not problem.
What wrong, and how can solve this problem and this commands have any error?

Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello,

"Ryanfai" <ry*****@yahoo.com> schrieb:
I use the vb.net make the program that save the date
and any Information field.
when I input the date in textbox then I save to database occurs
error that is
"Cast from string "20/08/2003" to type 'Date' is not valid.
I use this command change string to Date
dim year as date
dim strYear as string
=> year = ctype(stryear,Date).ADDYEAR(2)
I only in Windows 98 have problem
but In windows XP is not problem.
What wrong, and how can solve this problem and this
commands have any error?


I think that's caused by the format of the string (maybe it violates with
the locale settings of the computer). You may want to use 'DateTime.Parse'
instead.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2

P: n/a
Pass your date to this function and it will work fine.

Function ISODate(ByVal dteDate As Date) As String
If IsDate(dteDate) = True Then
Dim dteDay, dteMonth, dteYear
dteDay = dteDate.Day
dteMonth = dteDate.Month
dteYear = dteDate.Year
ISODate = dteYear & _
"-" & Right(CStr(dteMonth + 100), 2) & _
"-" & Right(CStr(dteDay + 100), 2)
Else
ISODate = Nothing
End If

End Function
--
Dino Buljubasic
Software Developer
http://rivusglobal.com

"Ryanfai" <ry*****@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I use the vb.net make the program that save the date and any Information
field.
when I input the date in textbox then I save to database occurs error that
is
"Cast from string "20/08/2003" to type 'Date' is not valid.
I use this command change string to Date
dim year as date
dim strYear as string
=> year = ctype(stryear,Date).ADDYEAR(2)
I only in Windows 98 have problem
but In windows XP is not problem.
What wrong, and how can solve this problem and this commands have any error?

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.