hi i want to have a sample on how to link a form to another. need help plzzzz friends. have to submit a project and i want to implement in in that.
i want to link a login page to a form. if login = True then direct to form else login fails.

Dani AI

Generated

This thread is about wiring a login screen to the rest of an app, and about managing multiple forms. The original ask from is a common pattern in VB.NET WinForms: authenticate first, then open the main UI only if authentication succeeds. and pointed to simple Show/ShowDialog approaches; those work for tiny demos but can lead to messy lifecycle, duplicated instances, and hard-to-maintain code as the project grows. wanted to link many forms — a few scalable options are outlined below. Also note ’s moderation points: keep replies focused and avoid thread hijacking.

A concise, maintainable WinForms pattern: perform authentication (in code, not just UI), then start the main form with Application.Run so the app lifecycle is clear. Example flow (simplified):

' Program.vb
Sub Main()
    Application.EnableVisualStyles()
    Application.SetCompatibleTextRenderingDefault(False)

    Using login As New LoginForm()
        If login.Authenticate() Then
            Application.Run(New MainForm(login.CurrentUser))
        End If
    End Using
End Sub

' LoginForm.vb
Public Function Authenticate() As Boolean
    ' validate credentials against your store and set CurrentUser
    Return ValidateCredentials(txtUser.Text, txtPass.Text)
End Function

For multiple windows: avoid opening lots of modeless forms. Options that scale:

  • Use an MDI parent or a single MainForm that swaps UserControls for different views.
  • Keep a dictionary of open child forms to avoid duplicates and to manage disposal.
  • Use events or constructor parameters to pass authenticated user info rather than globals.

For web/ASP.NET scenarios, do not try to “link forms” like desktop apps — use an authentication framework (ASP.NET Identity) and redirect on success. Security notes: never store plain-text passwords, use parameterized queries or an ORM, and dispose forms/connections properly.

Further reading: Application.Run and Windows Forms application lifecycle (Microsoft): https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.application.run?view=windowsdesktop-6.0
ASP.NET Identity (authentication best practice): https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-7.0

Recommended Answers

All 5 Replies

overload ShowDialog method make it returns true or false in case of true show second (main) form
your question is long but I'll tell you how to call a form from another one
this example calls form 2 from form number 1

dim form2 as Form2()
form2.ShowDialog()

iam requesting a code for linking many forms

iam requesting a code for linking many forms

Form2.Show()
        Form3.Show()
        Form4.Show()
        Form5.Show()

If you have more Forms than the above code, just add them to the list.

how can i create database with vb.net

commented: Don't hijack threads -3
  1. Don't hijack threads
  2. Don't resurrect old threads
  3. Show some effort before you post
  4. Provide some details
commented: You should make this post into a keyboard macro. You could use it a lot around here. +6
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.