469,621 Members | 1,820 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

String Convert to Date Time Problem is Windows 98

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
2 10989
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
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.

Similar topics

11 posts views Thread by jwf | last post: by
1 post views Thread by jwf | last post: by
22 posts views Thread by j1mb0jay | last post: by
8 posts views Thread by deepak_kamath_n | last post: by
3 posts views Thread by Jef Driesen | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.