Posts: 10
Threads: 7
Joined: May 2022
Reputation:
1
Code: (Select All) Function lDate$
p$ = "th"
If Val(Mid$(Date$, 4, 2)) <= 9 Then
day$ = Right$(Mid$(Date$, 4, 2), 1)
Else
day$ = Mid$(Date$, 4, 2)
End If
If Val(Mid$(Date$, 4, 2)) = 1 Or Val(Mid$(Date$, 4, 2)) = 21 Or Val(Mid$(Date$, 4, 2)) = 31 Then p$ = "st"
If Val(Mid$(Date$, 4, 2)) = 2 Or Val(Mid$(Date$, 4, 2)) = 22 Then p$ = "nd"
If Val(Mid$(Date$, 4, 2)) = 3 Or Val(Mid$(Date$, 4, 2)) = 23 Then p$ = "rd"
Select Case Val(Mid$(Date$, 1, 2))
Case 1: Month$ = "January"
Case 2: Month$ = "February"
Case 3: Month$ = "March"
Case 4: Month$ = "April"
Case 5: Month$ = "May"
Case 6: Month$ = "June"
Case 7: Month$ = "July"
Case 8: Month$ = "August"
Case 9: Month$ = "September"
Case 10: Month$ = "October"
Case 11: Month$ = "November"
Case 12: Month$ = "December"
End Select
lDate = day$ + p$ + " " + Month$ + " " + Mid$(Date$, 7, 4)
End Function
This code adds a function that will print a long date (21 February 2022) to the screen the instead of using date$ that would print 21-02-2022
Posts: 2,171
Threads: 222
Joined: Apr 2022
Reputation:
103
Nice! I love stuff like this. Here's what I used to d a lot of back in the 1990's, to save memory space...
Code: (Select All) dstring$ = "stndrdthththththth"
mstring$ = "January February March April May June July August SeptemberOctober November December "
DO
LINE INPUT "mo-day-year: ", xdate$
PRINT RTRIM$(MID$(mstring$, (VAL(MID$(xdate$, 1, 2)) - 1) * 9 + 1, 9)); " ";
PRINT LTRIM$(STR$((VAL(MID$(xdate$, 4)))));
IF MID$(xdate$, 4, 2) > "10" AND MID$(xdate$, 4, 2) < "21" OR VAL(MID$(xdate$, 5, 1)) = 0 THEN
PRINT "th, ";
ELSE
PRINT MID$(dstring$, VAL(MID$(xdate$, 5, 1)) * 2 - 1, 2); ", ";
END IF
PRINT MID$(xdate$, 7, 4)
PRINT
LOOP
I used what I termed as "Data Strings" to store info. Parse the string and display the results. Saving mem lead to a lot of obfuscated coding but at least it got the program working when space was an issue.
Pete
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
Even less LOC
Code: (Select All) Do
Line Input "mo-day-year: ", xdate$
Print RTrim$(Mid$("January February March April May June July August SeptemberOctober November December ", (Val(Mid$(xdate$, 1, 2)) - 1) * 9 + 1, 9)); " ";
Print LTrim$(Str$((Val(Mid$(xdate$, 4)))));
If Mid$(xdate$, 4, 2) > "10" And Mid$(xdate$, 4, 2) < "21" Or Val(Mid$(xdate$, 5, 1)) = 0 Then
Print "th, ";
Else
Print Mid$("stndrdthththththth", Val(Mid$(xdate$, 5, 1)) * 2 - 1, 2); ", ";
End If
Print Mid$(xdate$, 7, 4)
Print
Loop
b = b + ...
|