Instead use DateTime.TryParse.

Function dostuff(ByVal aDate As String) As String
    Dim isDate As Boolean
    Dim parsedDate As DateTime

    isDate = DateTime.TryParse(aDate, parsedDate)

    If (isDate)
        Return parsedDate.ToShortDateString()
    Else
        Return "Not a valid date"
End Function

HTH,
Ryan

Thank you,
Ryan Olshan
     Website - http://www.StrongTypes.com <http://www.strongtypes.com/>
     Group - http://groups.yahoo.com/group/StrongTypes
     Blog - http://blogs.strongcoders.com/blogs/ryan/


  _____ 

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
Joel Dickson
Sent: Sunday, April 30, 2006 10:32 PM
To: [email protected]
Subject: [AspNet2] Issue with Nullable Generic Structure



I'm having an issue with passing values from text boxes through to
the fill subroutines on my dataTableAdaptors.

Basically this is a simple example that illustrates my issue



     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

         MsgBox((Nothing = "").ToString) 'Returns "True"
         MsgBox(dostuff(Nothing)) 'Returns "not a date"
         MsgBox(dostuff("")) 'Throws Exception - Conversion from string
"" to type 'Date' is not valid.

      End Sub

     Function dostuff(ByVal aDate As System.Nullable(Of Date)) As String

         If aDate.HasValue Then
             Return CType(aDate, Date).ToShortDateString
         Else
             Return "not a date"
         End If

     End Function

I'm unsure what to do here, I tried to create a function to converts
empty strings to Nothing and execute that before passing the values of
the text boxes to the fill functions but that produces the same error.

Thanks in advance,

Joel




[Non-text portions of this message have been removed]






SPONSORED LINKS
Object
<http://groups.yahoo.com/gads?t=ms&k=Object+oriented&w1=Object+oriented&w2=P
rogramming+languages&c=2&s=48&.sig=f6H4QQqcmcp9kaxQRYmjcw> oriented
Programming
<http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=Object+oriente
d&w2=Programming+languages&c=2&s=48&.sig=r1ya7ggnEBNyfAH5-mYlDw> languages


  _____ 

YAHOO! GROUPS LINKS


     
*      Visit your group "AspNet2 <http://groups.yahoo.com/group/AspNet2> "
on the web.
 

*      To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
 

*      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .


  _____ 




[Non-text portions of this message have been removed]



SPONSORED LINKS
Object oriented Programming languages


YAHOO! GROUPS LINKS




Reply via email to