KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Sortable Date <DayNumbers> <MonthList> <Year>
Topic Summary: Output arbitrary sortable date
Created On: 01/08/2020 03:27 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Sortable Date <DayNumbers> <MonthList> <Year>   - Edgar - 01/08/2020 03:27 PM  
Keyword
 01/08/2020 03:27 PM
User is offline View Users Profile Print this message

Author Icon
Edgar
Top-Tier Member

Posts: 806
Joined: 04/03/2009

' The lists:
' DayNumbers consists of the integers 1 through 31
' MonthList consists of all 12 months January...December
' Year can consist of any list of consecutive integers, I use 1900...2050
' (I create consecutive lists of integers using a spreadsheet)

' I'm in the habit of using military dates: 8 January 2020 would come out sorted as: 2020 01 08
Sub Main
   Dim integerDayOfTheMonth As Integer
   Dim stringDayOfTheMonth, stringMonth As String
   Dim dayFailure As Boolean

   dayFailure = False
   integerDayOfTheMonth = CInt(ListVar1)
   If integerDayOfTheMonth >= 1 And integerDayOfTheMonth <= 31 Then
      If ListVar2 = "February" Then
         If integerDayOfTheMonth <= 29 Then' error testing for leap year is not performed
            stringDayOfTheMonth = ListVar1
          Else
            stringDayOfTheMonth = "UNKNOWN day"
            dayFailure = True
         End If
      ElseIf ListVar2 = "April" Or ListVar2 = "June" Or ListVar2 = "September" Or ListVar2 = "November" Then

         If integerDayOfTheMonth <= 30 Then
            stringDayOfTheMonth = ListVar1
          Else
            stringDayOfTheMonth = "UNKNOWN day"
            dayFailure = True
         End If
      Else
          stringDayOfTheMonth = ListVar1
      End If
   Else
       stringDayOfTheMonth = "UNKNOWN day"
       dayFailure = True
   End If
   If dayFailure = True Then
      MsgBox "The date uttered could not be parsed." + vbCr + _
         ListVar1 + " " + ListVar2 + " " + ListVar3, 0, "Date Unrecognized"
      Exit All
   End If

   stringDayOfTheMonth = Format (Val (stringDayOfTheMonth), "00")
   Select Case ListVar2
' since these are the only items on the list no need for error checking
      Case "January"
         stringMonth = "01"
      Case "February"
         stringMonth = "02"
      Case "March"
         stringMonth = "03"
      Case "April"
         stringMonth = "04"
      Case "May"
         stringMonth = "05"
      Case "June"
         stringMonth = "06"
      Case "July"
         stringMonth = "07"
      Case "August"
         stringMonth = "08"
      Case "September"
         stringMonth = "09"
      Case "October"
         stringMonth = "10"
      Case "November"
         stringMonth = "11"
      Case "December"
         stringMonth = "12"
   End Select

   SendKeys ListVar3, 1
   SendKeys "{Space}", 1
   SendKeys stringMonth, 1
   SendKeys "{Space}", 1
   SendKeys stringDayOfTheMonth, 1
End Sub


-------------------------

-Edgar
DPI 15.3, 64-bit Windows 10 Pro, OpenOffice & Word 365, Norton Security, Shure X2U XLR to USB mic adapter with Audio Technica DB135 vocal mic, Asus X299-Deluxe Prime, Intel Core i9-7940X (14 core, 4.3 GHz overclocked to 4.9 GHz), G.SKILL TridentZ Series 64GB (4 x 16GB) DDR4 3333 (PC4 26600) F4-3333C16Q-64GTZ, NVIDIA GIGABYTE GeForce GTX 1060 GV-N1060G1 GAMING-6GD REV 2.0 6GB graphics card

Statistics
31653 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 4473 on 07/17/2020 at 10:00 AM.
There are currently 399 guests browsing this forum, which makes a total of 399 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2020 FuseTalk™ Inc. All rights reserved.