Re: VB - An InputBox Form
An InputBox form is a great idea. However, what is the point of ButtonClicked? It does not seem to do anything to unload the form. One's own code must be added. The Index of the CommandButtons could be used directly instead of having the variables btnOK and btnCancel and checking their integers. The following looks pointless.
Code:
Select Case Index
Case btnOK
ButtonClicked = vbOK
Case btnCancel
ButtonClicked = vbCancel
End Select
:confused:
Re: VB - An InputBox Form
ButtonClicked is a Property that you can check from another form. For example in Form1
MsgBox frmInputBox.ButtonClicked
Re: VB - An InputBox Form
Quote:
Originally Posted by
Phantom1
However, what is the point of ButtonClicked? It does not seem to do anything to unload the form. One's own code must be added.
From the code of that form, it appears that inputbox form is hidden during cmdButton_Click. The routine that calls the frmInputBox.Display should also unload frmInputBox in my opinion.
Quote:
Originally Posted by Phantom1
The Index of the CommandButtons could be used directly instead of having the variables btnOK and btnCancel and checking their integers.
I think this is for convenience. You see Ok & Cancel buttons on the form, it makes sense to return a vbOk or vbCancel value instead of 0 or 1 for example. Just my opinion
For Martinliss. Suggest adding this to the Form_Unload event. Should a user unload the form by clicking the (X) close button, it will be registered as a cancel action
Code:
If ButtonClicked = 0 Then ButtonClicked = vbCancel
Re: VB - An InputBox Form
Thanks to you both for your suggestions and comments but this is just a template that you can to with as you want.
Re: VB - An InputBox Form
Quote:
Originally Posted by
MartinLiss
ButtonClicked is a Property that you can check from another form. For example in Form1
MsgBox frmInputBox.ButtonClicked
Quote:
Originally Posted by
LaVolpe
I think this is for convenience. You see Ok & Cancel buttons on the form, it makes sense to return a vbOk or vbCancel value instead of 0 or 1 for example.
I understand now.
I do not use all the properties, so I use a simpler InputBox form of my own. Nevertheless, I would not have thought of a form acting as InputBox without this thread.
:thumb: