I am brand new to Xojo and my goal is to build a custom scheduling and budgeting app for mac, windows and perhaps the web. A key component of this is being able to have my users enter times on a schedule with as few keystrokes as possible. I don’t really want to use pull down menus for this. I want times to be entered into text fields that then automatically format the text to the desired format.
A lot of this work is currently being done in Excel, and there the user can enter “7:30 p” and the software automatically sets the field to “7:30 PM” Even better would be if the user could enter “730p” and have the field show “7:30 PM” automatically. Eventually I would like to include an option for military time format, but that is not widely used at the moment by my end users.
The times entered are down to the minute like “12:01 PM” and sometimes I’ll need to show durations between times including the seconds.
I’m a complete beginner, but I know that this functionally is key to the success the project so I want to make sure this is possible before going too far down the path. Any comments appreciated.
I am brand new to Xojo and my goal is to build a custom scheduling and budgeting app for mac, windows and perhaps the web. A key component of this is being able to have my users enter times on a schedule with as few keystrokes as possible. I don’t really want to use pull down menus for this. I want times to be entered into text fields that then automatically format the text to the desired format.
A lot of this work is currently being done in Excel, and there the user can enter “7:30 p” and the software automatically sets the field to “7:30 PM” Even better would be if the user could enter “730p” and have the field show “7:30 PM” automatically. Eventually I would like to include an option for military time format, but that is not widely used at the moment by my end users.
The times entered are down to the minute like “12:01 PM” and sometimes I’ll need to show durations between times including the seconds.
I’m a complete beginner, but I know that this functionally is key to the success the project so I want to make sure this is possible before going too far down the path. Any comments appreciated.
[/quote]
There is no built in function to get the entry and turn it automatically into a computer representation. But Xojo string manipulation is elaborate enough to let you write the program needed to do what you describe. Durations can then be calculated automatically for you.
This can definitely be accomplished as you describe it. The idea for entering a time without a colon and with a trailing a/p is interesting so I put together a quick example. It doesn’t include a lot of basic error checking for invalid times but it should give you an idea of how this is possible. https://www.dropbox.com/s/3otm6zc6h5j2190/format%20of%20times.xojo_binary_project?dl=0
Good luck!
Thanks everyone! I can see this is possible mostly through looking at Jason’s example. Other ideas welcome still welcome. I’ve got a long way to go, but nice to see this should be possible.
Function getTime(s as string) as string
dim hr, mn as integer
dim ampm as string
dim n as integer
if right(s, 1) = "a" then
ampm = "a"
s = left(s, s.len-1)
elseif right(s, 1) = "p" then
ampm = "p"
s = left(s, s.len-1)
end
if CountFields(s, ":") > 1 then
hr = val(NthField(s, ":", 1)
mn = val(NthField(s, ":", 2)
else
n = val(s)
if n <= 12 then
hr= n
else
hr = floor(n/100)
mn = n - hr*100
end
end
if ampm = "" then
if hr < 7 then hr = hr + 12
if hr < 12 then ampm = "a" else ampm = "p"
end
s = str(hr) + ":" + format(mn, "00") + ampm
return s
end
I know. I am in a Yahoo Group where (almost UK People) use all kind of date format (presentation, not number representations 14xx for Muslims, 56xx for Jews and 2014 for the rest of the world ).
I recall a certain day: 04/04/04 it was a friend fathers birthday !