Custom DialogResult

is there anyway to have a custom result from a dialog?

instead of dialogresult.OK, dialogresult.cancel, etc,

could i create a custom result like DialogResult.PasswordOK?

thanks
LVL 13
newyuppieAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Usage:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Form1.MyShowDialog = MyResult.PasswordOK Then
            MsgBox("Password Accepted")
        Else
            MsgBox("Password Failed")
        End If
    End Sub



...and here is Form1...



Public Class Form1

    Public Enum MyResult
        PasswordOK
        PasswordInvalid
    End Enum

    Private result As Form1.MyResult

    Public ReadOnly Property MyDialogResult()
        Get
            Return result
        End Get
    End Property

    Public Shared Function MyShowDialog() As Form1.MyResult
        Dim f1 As New Form1
        f1.ControlBox = False
        f1.ShowDialog()
        Return f1.MyDialogResult
    End Function

    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If TextBox1.Text = "something" Then
            result = MyResult.PasswordOK
        Else
            result = MyResult.PasswordInvalid
        End If
        Me.Hide()
    End Sub

End Class
0
 
newyuppieAuthor Commented:
sorry for posting so late, you answered very promptly. i am checking that code right now and will award you the points if its working
0
 
newyuppieAuthor Commented:
idle_mind sorry for the delay i had to urgently take care of another business...

i tried the code and it does the trick for me, thank you very much for posting the full code! you get the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.