Solved

problem getting correct responce from default login dialog result.

Posted on 2009-06-29
2
177 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
ID: 24738226
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
ID: 31598005
OK I feel like a big ol lump now....  :)    thanks for the slap and the quick responce....  
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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