Solved

Use a Windows Form as a Function

Posted on 2006-11-03
2
207 Views
Last Modified: 2010-04-23
I have a login form I will be using a few times in my app.

How do i call this form like a function.  So the form is displayed and allow the use to confirm their login and when the form is closed it returns true or false.
0
Comment
Question by:Kevin Robinson
[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 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 17867945
You can show the form modally and then receive a DialogResult (which can be specified inside the login form) as a returned result.  Here's an example:

'Create the login form
Dim frmLogin As New LoginForm
Dim dlgResult As DialogResult = frmLogin.ShowDialog()

If dlgResult = DialogResult.Yes Then
      'Login successful
ElseIf dlgResult = DialogResult.No Then
      'Login failed
End If

--------------------
Inside the login form, you can set the result that will be returned like this:

                  Me.DialogResult = DialogResult.Yes

0
 
LVL 11

Expert Comment

by:melmers
ID: 17867951
In your Main form declare a public shared function where you display your form.
In all other forms call your shared function
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

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…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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