Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

problem getting correct responce from default login dialog result.

Posted on 2009-06-29
2
Medium Priority
?
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Bob Hoffman earned 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

704 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