Thank you for your enquiry.
I am not sure what you mean by “the best way” to (if I understand your question) use a form’s ModalResult property. If you look at the list of values for this property in the Object Inspector (open the drop-down list), I believe all of them except for mrNone will close the form.
Suppose you have a form with multiple buttons (OK, Cancel).
- If you want to do some validation when the user clicks OK, then at design time set the ModalResult property of the OK button to mrNone (as in your example). Your validation routine (eg. an event handler for the OK button) should not need to set the form’s ModalResult unless the input is valid, ie. ModalResult = mrOK. (If the form is displayed more than once you might need to reinitialize ModalResult to mrNone.)
- No validation should be necessary for Cancel, so this button’s ModalResult property should be mrCancel, so the form will close automatically.
Suppose your applet has two forms, FormA and FormB, and that FormA shows FormB. You can choose the possible ModalResult values for FormB (or the buttons on FormB) to suit the needs of FormA. The following code shows an example:
dim iChoice iChoice = FormB.ShowModal if iChoice = mrYes then ' do something for Yes option... elseif iChoice = mrNo then ' do something for No option... elseif iChoice = mrCancel then ' cancel the process end if
The choice between DateTimePicker and RzDateTimeEdit is largely aesthetic. I would choose the one that seems easiest for users. See the online Help files for these controls; RzDateTimeEdit offers some additional functionality that may simplify your work.
To format the date value, you can use the VBScript functions:
iText = FormatDateTime(DateTimePicker1.Date, vbShortDate) msgbox iText iYear = Year(DateTimePicker1.Date) iMonth = Month(DateTimePicker1.Date) iDay = Day(DateTimePicker1.Date) iText = iMonth & "/" & iYear & "/" & iDay msgbox iText
See the VBScript online Help for details.
I hope this helps.
[This message was edited by Support 1 on July 12, 2006 at 07:08 PM.]