Click here to Skip to main content
13,042,630 members (81,763 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I have a login screen where the user will input their First and Last Name. I would like the first and last name to appear at the top of each screen. Can someone help?


Here is my code...could you tell me how I can display the username from "loginForm" into this form?

Imports System.ComponentModel

Public Class escalationForm

    Private Sub escalationForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        My.Computer.Audio.Play(My.Resources.Adan, AudioPlayMode.Background)
        'Automatically plays audio file
    End Sub
    Private timer1 As New Timer
    Public Sub New()
        ' This call is required by the designer.
        ' Add any initialization after the InitializeComponent() call.
        timer1.Interval = 34000
        timer1.Enabled = True
        AddHandler timer1.Tick, AddressOf Timer1_Tick
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim f2 As New introTask2
        timer1.Enabled = False
    End Sub
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        'Displays the First Name, Last Name, Date and Time
        Label9.Text = "Time: " + TimeString
        Label10.Text = "Date: " + DateString
        Label12.Text = "First Name: " + loginForm.TextBox1.Text
        Label11.Text(-"Last Name: " + loginForm)
    End Sub
End Class
Posted 18-May-11 23:00pm
Updated 19-May-11 8:02am
SAKryukov 19-May-11 14:00pm
Tag it! What is the language, platform, UI library?!
SAKryukov 20-May-11 12:56pm
Please don't post your code as solution, if it is not a solution. Use "Improve question", "Add Comment" or reply to other comment.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Save it in the Session; set it in the page load.

How to do it will differ slightly depending on your web site coding method, but Google for "using Session variable" with your chosen language should find it ok.
SAKryukov 19-May-11 14:01pm
What session? OP writes the code in Windows.Form, it looks like. This is OP's fault of course.
SAKryukov 19-May-11 14:09pm
I added my recommendation for Forms, please see.
OriginalGriff 19-May-11 14:30pm
It said Page when I answered! :laugh:
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

This is the most robust solution for inter-form collaboration: implementing appropriate interface by the form class.

Please see my past answer:
How to copy all the items between listboxes in two forms[^].

Some notes: you suffer from such a dirty code. The names like "label1", "label2" violate (good) Microsoft naming conventions. You should never leave Designer-generated names, rename them to some semantic names. Using times in most cases is quite a bad idea. Prefer thread to stay out of trouble. (See, for example, my past answer here: Timer Threading in C#[^].)

Rate this: bad
Please Sign up or sign in to vote.

Solution 4

After login Save username in variable and use this variable in every form where you want to display name.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 20 May 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100