Timer and form1.text

Jynx

Active member
Joined
Oct 20, 2007
Messages
44
Programming Experience
Beginner
Hey guys I need some assistance! (still learning..I'll be there some day).

I've gotten a lot done so far with my project but I am stuck on a couple of different things.

My program has a login screen that occurs after the splash.
Its simply FirstName in textbox1 and LastName in textbox2.

Now, when you click ok form1 starts.
Form1 should have the FirstName LastName as its form1 text title.

I can only get it to show the contents of the textbox1 (that being the firstname). I don't know how to show both the contents of the box's there.

Public Class LoginForm1
Friend firstname As String
Friend lastname As String

firstname = TextBox1.Text
firstname = TextBox2.Text
END CLASS

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Me.Text = LoginForm1.firstname

End Sub

My second problem is I have a form with 2 buttons. A start timer and stop timer.

I can start the timer, then I can stop the timer and displayer the stopped time in a text box. I however need it to show the difference between the 2. I need it to for example say "Its been 12 mins 25 seconds" - or something similar - format doesn't matter too much.
 
For issue #2, when you click the Start button, set a datetime variable equal to "Now" then in the stop button set a second datetime variable equal to "Now" then use the timespan class to compare the two times. The timespan class also handles dates too.
 
.NET already has a Stopwatch class. You should use one. It works pretty much as you'd expect a stopwatch to work, with methods like Start, Stop and Reset. The Elapsed property will return a TimeSpan value containing the elapsed time.

As for your first question, you could join the names like this:
VB.NET:
LoginForm1.FirstName & " " & LoginForm1.LastName
but I'd sooner see this:
VB.NET:
String.Format("{0} {1}", LoginForm1.FirstName, LoginForm1.LastName)
 
Back
Top