Does anyone here have the CalendarControl from piDog, and know if it is possible to have the default start date populated from a textfield or variable string in the main window?
My boss is nagging me and needs an answer by the morning - so although I have emailed Jim from piDog, I dont expect an answer from him until tomorrow afternoon. Therefore, I thought I would try on here in the meantime, and see if anyone knew the answer (and if so, how).
Not to offend you, but you are stumbling around just like I used to do, and the reason seems to be that you don’t even know what type something is.
Of course it fails when you try to stuff a date object into a string. So look at the documentation and pay particular attention to what type each propert is.
It reminds me of physics in school where some people got “units” (you can’t stuff inches into ounces) and some don’t.
In case you don’t know whom I’m referring to: he is one of the Xojo demigods, his answers are like the oracle of Delphi, but you better listen to him because he KNOWS. But what he mostly knows is that simply giving you the solution isn’t really helping you become a better programmer. It is better to tell you where to find the solution and let you work it out for yourself. THAT’S what helps you become a better programmer
Markus
I am not trying to stuff anything into anything? I was trying to convert a Date into a String.
If I got an error stating “expected String but got a Date”, then I am being told that the 2 formats are different.
therefore the code examples I tried, were trying to convert that Date value into a string value, and then display it in a TextField.
All 3 of my attempts made perfect sense to me, as they were different ways of saying "Take the date object, make the contents (properties) a Text only string, and then put it into a TextField.
Yes - I am only a VERY part-time user of Xojo, and DO NOT understand a lot of concepts, BUT I do always attempt to find the solution myself - hence my attempts above. In fact I often spend days trying different solutions before I ask for help.
If you know where to look in the Language Reference, it is much easier - BUT, If you have no idea what you need to be looking for, then it is impossible
I totally agree with you - just giving someone the solution doesn’t really help the person, as they still won’t really understand the concept.
I did read the Language Reference on Dates - but there was nothing there on converting from one type to another, so I was stuck.
Anyway - no offence was taken - I just wanted to clarify that I did try to solve the problem myself.
Thank you for your guidance, and I appreciate all comments.
[quote=70227:@Richard Summers]Markus
I am not trying to stuff anything into anything? I was trying to convert a Date into a String.
If I got an error stating “expected String but got a Date”, then I am being told that the 2 formats are different.[/quote]
Actually that error tells you that you were indeed trying to “stuff” a round peg (a date object) into a square hole (a string).
An object has properties that you can access. Some are read-only, others you can read and set. That is what you need to do here.
In other cases there are functions which convert from one SCALAR type to another, like VAL to convert from string to integer.
If you read the documentation on date then you need to pay particular attention to what type the date properties are, which ones you can only read, which ones you can set.
I think this is also a case of you speaking in technical terms and me speaking in layman’s terms
I understand that the Date object is like a container. This container holds Integer values for the properties such as seconds, minutes, hours etc. etc.
Where I went wrong, is I thought that the following code:
fldDate.text=myCalendarClass.SelectedDate
would take the combined values stored in “SelectedDate”, and then display them as a String in the TextField.
I did not realise that I needed to specifically set those values to the “.ShortDate” String format, at the end of the code, before I could do this.
I presumed that as “SelectedDate” contained the values 25 12 2014, I could therefore simply display them as a String.
Hope that made more sense to you, and you can understand where I was coming from.
Once again, thank you for all your help - the problem is now solved.
But it doesn’t. SelectedDate contains a date object. That date object has integer properties like day, month, year which contain the values you are after.
Conceptual problems arise when users mix up an object with the properties they contain (or even worse the property values). An example of that is when users try to compare two dates like this
If currentDate = todaysDate then
When in reality they want to know if both date objects have the same values.
What the above code is doing is ask if the two objects are identical to each other, not whether they contain the same date values.
Ok, as an example - lets say todays date is christmas day.
If I typed:
Dim CurrentDate as New Date
I would expect a Date object called CurrentDate to be created, with the value 25 for the day property, 12 for the month property, and 2014 for the year property.
Are you saying then, that CurrentDate would NOT contain these values for those properties, BUT INSTEAD, CurrentDate would contain a date object that contains those values for the properties?
I personally, would expect CurrentDate to be the Date object - but If I have understood you correctly: CurrentDate is at the top of the hierarchy, then a date object, then the values for the properties.
So basically:
Dim CurrentDate as New Date
Is saying - Create a top level hierarchy object called CurrentDate, and place inside that, a Date object containing those values.
If I am correct so far, then:
Dim CurrentDate as New Date
seems to be a bit of a misnomer due to the word AS. The word AS implies that CurrentDate will be the date object, as opposed to an object above it.
Just when I think I understand something - it seems I don’t
CurrentDate is the name of a variable of type date.
In that sense CurrentDate IS the date object in the same way that Richard Summers is you. [Note that Richard Summers is also the value of the name property of the Richard Summers person. You might change the name property but it is still the same Richard Summers person].
However the date object doesn’t contain VALUES, it contains PROPERTIES which have certain values.
I was objecting to “I presumed that as “SelectedDate” contained the values 25 12 2014” as this is not correct.