Solved

problem getting correct responce from default login dialog result.

Posted on 2009-06-29
2
171 Views
Last Modified: 2012-05-07
Hello all:

   I have a small issue that I can;t seem to figure out.  I am useing a sub main() to start my app and to display a login form....   the problem that I am having is that weither the user clock "OK" or "Cancel" my result code is always windows.form.dialogresult.cancel....   what gives?

I put a couple of msgbox's in place to test and make sure I didn't have the labels messed up or something like that...


Public Sub Main()

        Dim LogIn As New LoginForm()

        Dim result As DialogResult

        result = LogIn.ShowDialog

        MsgBox(result.ToString)

        If result = Windows.Forms.DialogResult.OK Then

            'validate user here

            Application.Run(New MainForm)

        End If

    End Sub
 
 

Public Class LoginForm
 

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        MsgBox("Clicked ok")

        Me.Close()

    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

        MsgBox("Clicked cancel")

        Me.Close()

    End Sub

End Class

Open in new window

0
Comment
Question by:MedSouth
2 Comments
 
LVL 8

Accepted Solution

by:
Bob Hoffman earned 500 total points
Comment Utility
You need to set the DialogResult... see below
 Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        MsgBox("Clicked ok")

        Me.DialogResult = Windows.Forms.DialogResult.OK

        Me.Close()

    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

        MsgBox("Clicked cancel")

        Me.DialogResult = Windows.Forms.DialogResult.Cancel

        Me.Close()

    End Sub

Open in new window

0
 

Author Closing Comment

by:MedSouth
Comment Utility
OK I feel like a big ol lump now....  :)    thanks for the slap and the quick responce....  
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now