Answered by:
error

Question
-
User364480375 posted
Private Function validateDate(ByVal strDate As String) As Boolean If strDate = "" Then ' empty allowed, so OK Return True End If Dim dt As DateTime = New DateTime(0) Dim ci As System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture If DateTime.TryParseExact(strDate,"dd/MM/yyyy",ci,System.Globalization.DateTimeStyles.None,ref dt)) Then ' valid date as parsing succeeded Return True End If ' error Return False End Function
error : ref is not declared nd comma,')', validation continuation expression expected
Wednesday, September 16, 2015 5:27 AM
Answers
-
User37182867 posted
Private Function validateDate(ByVal strDate As String) As Boolean If strDate = "" Then ' empty allowed, so OK Return True End If Dim dt As DateTime = New DateTime(0) Dim ci As System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture If DateTime.TryParseExact(strDate,"dd/MM/yyyy",ci,System.Globalization.DateTimeStyles.None,ref dt)) Then ' valid date as parsing succeeded Return True End If ' error Return False End Function
error : ref is not declared nd comma,')', validation continuation expression expected
The above striked line is not valid VB. Replace with below. ( Untested but should work )
If DateTime.TryParseExact(strDate,"dd/MM/yyyy",ci,System.Globalization.DateTimeStyles.None, dt) Then
In VB you do not pass in parameters with the "ref" command like C# uses the "out" command. The signature of the method determines how the input parameters is used.
See this link for MS's definition https://msdn.microsoft.com/en-us/library/ddck1z30.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 16, 2015 8:03 AM -
User37182867 posted
there is no such thing as an "out" in VB you just simply assign it as "By Ref" in the signature and in the method call give it a variable to use.
If converting between C# and VB why not just use something like http://converter.telerik.com/
Which is probably better and faster at converting it than anyone who isnt familiar one language or the other.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 16, 2015 11:48 AM
All replies
-
User37182867 posted
Private Function validateDate(ByVal strDate As String) As Boolean If strDate = "" Then ' empty allowed, so OK Return True End If Dim dt As DateTime = New DateTime(0) Dim ci As System.Globalization.CultureInfo = System.Globalization.CultureInfo.InvariantCulture If DateTime.TryParseExact(strDate,"dd/MM/yyyy",ci,System.Globalization.DateTimeStyles.None,ref dt)) Then ' valid date as parsing succeeded Return True End If ' error Return False End Function
error : ref is not declared nd comma,')', validation continuation expression expected
The above striked line is not valid VB. Replace with below. ( Untested but should work )
If DateTime.TryParseExact(strDate,"dd/MM/yyyy",ci,System.Globalization.DateTimeStyles.None, dt) Then
In VB you do not pass in parameters with the "ref" command like C# uses the "out" command. The signature of the method determines how the input parameters is used.
See this link for MS's definition https://msdn.microsoft.com/en-us/library/ddck1z30.aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 16, 2015 8:03 AM -
User1428246847 posted
deadtroll
The above striked line is not valid VB.Mike (?) is trying to convert C# code that I posted elsewhere. It was initially an out parameter in C# but that did not work, so I changed it to ref. Also does not seem to work.
And I'm not a VB person
Wednesday, September 16, 2015 11:25 AM -
User37182867 posted
there is no such thing as an "out" in VB you just simply assign it as "By Ref" in the signature and in the method call give it a variable to use.
If converting between C# and VB why not just use something like http://converter.telerik.com/
Which is probably better and faster at converting it than anyone who isnt familiar one language or the other.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, September 16, 2015 11:48 AM -
User364480375 posted
Guys confusedb little bit. Wht code i should try??Wednesday, September 16, 2015 11:54 PM -
User364480375 posted
thnks deadtroll and wims
Thursday, September 17, 2015 9:47 AM