10-28-2016, 11:29 AM
Polymath (in disciplina)
* Expert *
Join Date: May 2004
You could just change 'Time' to 'Now', but then the date would be spoken first, which might be acceptable to you.
However, I wanted to demonstrate slightly cleaner code (and correct the date/time order in the process):
name = "Brian"
Set sapi = CreateObject("sapi.spvoice")
If Hour(Now) < 12 Then
wish = name & ",Good Morning. "
ElseIf Hour(Now)<17 Then
wish= name & ",Good Afternoon. "
wish = name & ",Good Evening. "
sapi.Speak wish & name & ", the time is " & Time & " " & Date
Notice, among other things, that I changed the concatenation character from '+' to '&', which eliminates the need for 'cstr' to do the explicit type conversion. However, many programmers would use both the '&' and 'cstr' to document that we are working only with string data and that the date/time are not intrinsically strings.
I'm moving this VBScript related topic to 'Miscellaneous Languages', since it is not really VB6.
I got all the answers wrong on the GLAT, apparently even #9 (where I put a period in the middle of the box and labeled it 'singularity ripe for rapid inflation').
Last edited by Cerian Knight; 10-28-2016 at 11:49 AM.