Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > forms with names


Reply
 
Thread Tools Display Modes
  #1  
Old 05-21-2001, 01:16 PM
johnjr
Guest
 
Posts: n/a
Default forms with names


hi all....does anyone have code which will allow me to enter my details like name on a form with a textbox and then for the prog to write the name on the blue bar across the top of the mainform.when the program next runs..it must display the name everytime....can someone help


thanks


Reply With Quote
  #2  
Old 05-21-2001, 01:25 PM
JDT JDT is offline
Original Contributor

Retired Moderator
* Guru *
 
Join Date: Jan 2001
Location: Watch Window
Posts: 2,781
Default Re: forms with names

If you are trying to have the text in a text box become the title of the window everytime the program runs then I would use the registry to store that data for me.

<pre>Private Sub Form_Load()

Me.Caption = GetSetting("App_Name", "Startup", "Caption", "Default_Name")

End Sub

Private Sub Form_Unload(Cancel As Integer)

SaveSetting "App_Name", "Startup", "Caption", Text1.Text

End Sub</pre>

JDT

__________________
JDT
Reply With Quote
  #3  
Old 05-22-2001, 12:19 AM
johnjr
Guest
 
Posts: n/a
Default Re: forms with names

hi.thanks for the code......could i use a form with a textbox on it requesting ones name and only when it was entered would it load the mainfrm ???


Reply With Quote
  #4  
Old 05-22-2001, 01:54 AM
JDT JDT is offline
Original Contributor

Retired Moderator
* Guru *
 
Join Date: Jan 2001
Location: Watch Window
Posts: 2,781
Default Re: forms with names

Yes you could do that. Here is an example that uses the InputBox instead of a form. You could easily change the code if you realy want to use a form to get the name.

<pre>Option Explicit

Private Sub Form_Load()

Dim blnCancelLoop As Boolean
Dim strMessage As String
Dim strInput As String

strMessage = "What is your name?"

Do

strInput = InputBox(strMessage, "Name", "Your name here")

If StrPtr(strInput) = 0 Then '<-------------Cancel was pressed
blnCancelLoop = True '<-------------------End loop
Unload Me '<------------------------------Quit program
ElseIf strInput = vbNullString Then '<------Pressed OK with no text
strMessage = "You must enter something."
blnCancelLoop = False '<------------------Continue loop
Else '<-------------------------------------Name was entered
Me.Caption = strInput '<------------------Set caption to name
blnCancelLoop = True '<-------------------End loop
End If

Loop Until blnCancelLoop = True

End Sub</pre>

JDT

__________________
JDT
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->