Making Custom Prompt Forms like MessageBox

04-24-2004, 01:33 PM
Here are some sample VB.NET form classes for making prompts in your program.

In each .vb file, you will find the Form class is not shown directly, but is shown by the second class, making a .ShowDialog call to the Form class:

Public Overloads Shared Function Show() As Integer
Dim NB As NumberBox
Dim X As Integer
NB = New NumberBox
'Instantiates the prompt numberbox

'If OK was pressed, there's something waiting for me in the .MyValue property.
If NB.ShowDialog() = DialogResult.OK Then 'Shows the form.
X = NB.MyValue
'Get it.
X = -1
'-1, the default value.
End If

'Return the value that we get.
Return X
'You might find the other show functions are very similar to this one.
'Also, the other classes have show functions similar to this.
'Good luck.
End Function
So, for each .vb file:
There is a class with multiple Shared Show functions.
These show the prompt form, using the New constructor to initialize the form (we do provide parameters for those multiple Shared Show functions, so they must be passed to the form)
The DialogResults are set for the OK and Cancel Button...
When the OK button is pressed, the prompt form data is written into RetVal (get this using .MyValue from the multiple Shared Show functions)
and from the Show function, the result is returned.

Enclosed are the NumericBox (selecting a number from a prompt),
the ArrayBox (selecting an array member from a prompt),
and the StringBox (like the InputBox where you type in a string from the prompt).
Good luck and enjoy!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum