[Gambas-user] IsDate(string) - how good is it?

Gianluigi bagonergi at gmail.com
Thu Jan 6 10:36:06 CET 2022


Il giorno gio 6 gen 2022 alle ore 09:44 Gianluigi <bagonergi at gmail.com> ha
scritto:

>
>
> Il giorno gio 6 gen 2022 alle ore 09:39 Gianluigi <bagonergi at gmail.com>
> ha scritto:
>
>>
>>
>> Il giorno gio 6 gen 2022 alle ore 09:15 bb <adamnt42 at gmail.com> ha
>> scritto:
>>
>>> By that I mean, what type of strings can be interpreted as a date?
>>>
>>> For example, IsDate("1/Jan/2022") returns false.
>>>
>>> I am trying to determine whether a gridview cell is actually a date,
>>> but gridviews only have string contents. My human brain immediately
>>> interprets that string as a date but IsDate doesn't. So what are the
>>> "limits" of what IsDate() can interpret?
>>>
>>> b
>>>
>>>
>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>>
>>
>> Have you tried like this: IsDate(Val("1/Jan/2022")) ?
>>
>
> Sorry: IsDate(Str(Val("1/Jan/2022")))
>

In fact it is obtained from very winding passages, boh!

es.
[code]
Private hGrid As GridView

Public Sub Form_Open()

  Dim aHeaders As String[] = ["DATE", "ID", "MIKEY", "MINNIE"]
  Dim hPan As HBox
  Dim hButton As Button
  Dim hDate As Date

  hGrid = New GridView(Me) As "GridView1"

  With Me
    .H = 512
    .W = 512
    .Arrangement = Arrange.Vertical
    .Margin = True
  End With
  With hGrid
    .Resizable = True
    '.AutoResize = True
    .Expand = True
    .Header = GridView.Horizontal
    .Rows.Count = 10
    .Columns.Count = aHeaders.Count
    .Columns[0].Width = 10
  End With

  For i As Integer = 0 To aHeaders.Max
    hGrid.Columns[i].Title = aHeaders[i]
  Next
  For i = 0 To 9
    hDate = Date(Year(Now), Month(Now - i), Day(Now - i))
    hGrid[i, 0].text = Format(hDate, "dd/mmm/yyyy")
  Next
  hGrid.Columns.Width = -1

  With hPan = New HBox(Me)
    .h = 40
  End With
  With hButton = New Button(Me) As "Button1"
    .h = 40
    .AutoResize = True
    .Text = "CLICK HERE"
  End With

End

Public Sub Button1_Click()
  ' IsDate(Str(Val("1/Jan/2022")))
  Dim hDate As Date = Date(Val(hGrid[0, 0].text))

  Print IsDate(Str(hDate))
  ' Print IsDate(Str(Date(Now)))

End
[code]

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220106/d1740d82/attachment.htm>


More information about the User mailing list