Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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?
 
[EDIT]
 
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.
        InitializeComponent()
 
        ' 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
        PrintForm1.Print()
        f2.Show()
        timer1.Enabled = False
        Close()
    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 19-May-11 0:00am
Edited 19-May-11 9:02am
v2
Comments
SAKryukov at 19-May-11 14:00pm
   
Tag it! What is the language, platform, UI library?!
--SA
SAKryukov at 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.
--SA
Rate this: bad
good
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.
  Permalink  
Comments
SAKryukov at 19-May-11 14:01pm
   
What session? OP writes the code in Windows.Form, it looks like. This is OP's fault of course.
--SA
OriginalGriff at 19-May-11 14:30pm
   
It said Page when I answered! :laugh:
SAKryukov at 19-May-11 14:09pm
   
I added my recommendation for Forms, please see.
--SA
Rate this: bad
good
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#[^].)
 
—SA
  Permalink  
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 195
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 20 May 2011
Copyright © CodeProject, 1999-2014
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