Solved

Use a Windows Form as a Function

Posted on 2006-11-03
2
166 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
2 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

8 Experts available now in Live!

Get 1:1 Help Now