/ Forums / Advansys Formativ / Creating Solutions with Formativ / DateTimePicker
-
CreatorTopic
-
September 30, 2008 at 6:33 am #4394
Hello Support Team,
i use this code in my form to change the Label value with the date value that the user put it in the DateTimePicker , but it doesent work…
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
Me.Label1.Text = CStr(Me.DateTimePicker1.Value)
End SubWhen i use it in my Visual Studio 2008 it works fine…
and in the object inspector in formativ there is no eventhandler called “DateTimePicker_ValueChanged” like in Visual Studio 2008…
Do you have some tips for me?
PS: off course i have changed Me.Label1.Text to the names of objects i use in my apllet like xxxx.Label1.Text and so on..
thanks for help
-
CreatorTopic
-
AuthorReplies
-
September 30, 2008 at 6:15 pm #8072
Thanks for your enquiry.
To create a handler for DateTimePicker’s OnChange event, double-click the edit box at OnChange in the Object Inspector. For a DateTimePicker named Picker1, this creates a Sub like that shown below:
Sub Picker1Change(Sender) End Sub
There is no Value property for DateTimePicker (the Object Inspector displays the properties Date and Time).
If MainForm has a Label named Label1 for displaying the date as it changes, you could modify the handler as below:
Sub Picker1Change(Sender) MainForm.Label1.Caption = DateToStr(MainForm.Picker1.Date) End Sub
You can also use the VBScript functions listed below to help with formatting date/time values:
Hour Minute Second Weekday Day Month Year
You may find it helpful to compare DateTimePicker with the RzDateTimeEdit control (on the Enhanced tab). This control has the event OnDateTimeChanged along with a range of different properties.
I hope this helps.
Regards,
Advansys SupportOctober 2, 2008 at 6:29 am #8068thanks a lot, it was very helpfull and it works fine…
i am trying to code a CheckDateRange function now… i try it by my own first…
Regards
October 2, 2008 at 4:28 pm #8063Thanks for your feedback.
Regards,
Advansys SupportOctober 6, 2008 at 7:08 am #8074Hey guys,
now i have two problems… in my code now it works fine when i put a start and end date in the DateTimePicker calender to get only workdays of a week in my field workdays..I put these routine in the Sub PickerEndeChange(Sender) Event Handler…
So my two problems now are, that if the user put the start and end date manually in the fields nothing happens… i think i have to put the routine from the event handler in the main function, but how? and the other thing is, that i want to check if the date was putting correct, because start date can not be bigger then the end date ( if startDate > endDate ?? )
here is my code:
Sub Main(Client, GWEvent)
.
.
.
End Sub‘ Datefunction Start
Sub PickerStartChange(Sender)
TasoUrlaub.feldStart.Text = DateToStr(TasoUrlaub.PickerStart.Date)
End Sub‘ Datefunction End
Sub PickerEndChange(Sender)
TasoUrlaub.feldEnd.Text = DateToStr(TasoUrlaub.PickerEnd.Date)Dim fromDate
Dim toDate
fromDate = TasoUrlaub.PickerStart.Date
toDate = TasoUrlaub.PickerEnd.Date
Dim n
Dim i
Dim d
Dim s
Dim wn = DateDiff(“d”, fromDate, toDate)
For i = 0 To n
d = DateAdd(“d”,i, fromDate)
w = WeekDay(d)
If w <> 7 AND w <> 1 Then s = s + 1
Next
TasoUrlaub.feldWorkDays.text = s & ” without holidays”End Sub
thanks for your help…
October 6, 2008 at 8:18 pm #8069>if the user put the start and end date manually in the fields nothing happens…
I am not sure what you mean by “fields”. Are you referring to the DateTimePicker or Edit control? I suggest that you permit users to choose dates using only the DateTimePicker.
You can compare the Date properties of two DateTimePicker controls as shown in the example below:
'Datefunction Start Sub PickerStartChange(Sender) dim fromDate dim toDate fromDate = TasoUrlaub.PickerStart.Date toDate = TasoUrlaub.PickerEnd.Date if toDate > fromDate then MsgBox "Start date cannot be later than End date." end if End SubYour OnChange handler can also be used to fix an incorrect date after a user has broken the rule, as shown below:
'Datefunction Start Sub PickerStartChange(Sender) dim fromDate dim toDate fromDate = TasoUrlaub.PickerStart.Date toDate = TasoUrlaub.PickerEnd.Date if toDate > fromDate then MsgBox "Start date cannot be later than End date." TasoUrlaub.PickerStart.Date = TasoUrlaub.PickerEnd.Date end if End SubAnother option is to use the OnUserInput event if you want to prevent a change to the date that breaks the rule. Note that you will need to edit the handler that is created automatically – add the ByRef keyword as shown below:
Sub PickerStartUserInput(Sender, UserString, DateAndTime, ByRef AllowChange)
dim fromDate dim toDate fromDate = TasoUrlaub.PickerStart.Date toDate = TasoUrlaub.PickerEnd.Date if toDate > fromDate then AllowChange = false end ifEnd Sub
In addition, I suggest using the built-in VBScript named constants, eg. vbSaturday, vbSunday instead of “magic numbers” like 7, 1, etc.
I hope this helps.
Regards,
Advansys Support[This message was edited by Support 1 on October 06, 2008 at 08:28 PM.]
October 6, 2008 at 11:58 pm #8067Hi Support 1,
thanks for your help… and again it helps me a lot…
yes i meant the edit controls, i need to give the user the chance to put the Date in the DateTimerPicker or manually in the edit controls… but how? is that right that i have to put the the code in the main function also?
thanks for your help…
October 7, 2008 at 6:03 am #8070Hi,
ignore my last post.. i was working with edit controls, of course there was nothing happens when i was putting the date manually
I cutted the the edit controls out and only working now with the DateTimerPicker… and i fix the other problem by working with Maxdate & MinDate Properties of the DateTimePicker Class…I have one more question, is it possible to send the values or the result of my Form/Inquiry to 2 mail accounts as text mail in groupwise ( one for the CEO and the other mail for the one who is making the Inquiry)
How can i fix that ? Hope you understand what i mean…
October 7, 2008 at 3:31 pm #8064Please see the Developers Guide for more information and sample code. The following sample code lets you to send message.
Dim objDraft Dim objEmail Dim objRecipient ' Create a draft email message Set objDraft = GroupWise.Account.workfolder.Messages.Add(4) ' Add a single recipient - ourself objRecipient = objDraft.Recipients.Add(objDraft.Sender.EmailAddress,,0) ' Add some properties objDraft.Subject = "This was created using Formativ" objDraft.BodyText.PlainText = "This is the body text of the email message" ' Send the email by calling the send method Set objEmail = objDraft.Send ' Display the MessageID MsgBox(objEmail.MessageID)Regards,
Advansys SupportOctober 8, 2008 at 4:29 am #8066thanks..
i do it that way and evrything works fine.. but i have still 2 problems, how can i add two recipients?
and the other thing is:
With objMessage
.Subject = “xxxx”
.Bodytext = DateTimePicker.DateHere always cames out a freaky number, but i want to display the inputed Date ??
Thas all, thanks for now…
October 8, 2008 at 7:56 am #8065ok i fixed the first thing with two recipients…
but i have still the problem with DateTimePicker ;(
October 8, 2008 at 4:55 pm #8071You can use the FormatDateTime() function to return the date or time expression. See the “Visual Basic Scripting” guide for more information.
msgbox FormatDateTime(Maindlg.DateTimePicker.date, vbGeneralDate)
Regards,
Advansys SupportOctober 9, 2008 at 2:48 am #8073thanks works fine

-
AuthorReplies
- You must be logged in to reply to this topic.