Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting all form text properties to same thing

Status
Not open for further replies.

datamasher

Technical User
Dec 31, 2001
69
GB
Hi everyone,
How can I allow an end user of an application to set the text property of all the forms in an application to read the same thing during runtime. e.g. The first time a user runs an application they can customize the text property in the forms to their company name. e.g. ABC Widgets Corp.

Steve
 
You might want to store the information in a public variable and then populate the correct text field when the form loads.

{Module}
Public CompanyName as String

{Form}
Private Sub Form2_Load()Handles Form2.Load
TextBox1.Text = CompanyName
End Sub
 
Hi QamGine,
I tried this method myself but it doesn't do what I want it to do. I'll try and explain better.
I want the user to be able to customize the form captions so the form captions display their company name. e.g. ABC Widgets
: View Customers Form. This is the forms text property.

Each time the application is run though the public variables in the module reset so they have to enter the information again. I need the information to be stored somehow so they only ever have to enter it once.

I can't think of another way of doing it !

Steve

 
Hi Everyone,
after a lot of digging around in MSDN and stumbling about I've managed to do what I wanted.

I was unaware of Applications Settings until I found them on the Designer IDE. I was able to set a variable string Company Name in the Settings and then when the user enters his company name into a text box on a form this replaces the string value in the Settings and it persists even after the application is closed.
I can then access this Settings variable and use it at will in the code. These are some snippets I used :-

<code>

On Customise Form

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newGroupName As String
newGroupName = TextBox1.Text
ChangeGroupName(newGroupName)
My.Settings.Save()
End Sub

Public Sub ChangeGroupName(ByVal newGroupName As String)
My.Settings.GroupName = newGroupName
End Sub

End Class

On all other forms

Public Class FormXXX

Private Sub FormXXX_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Text = My.Settings.GroupName & " : Add New Members"
End Sub
End Class

</code>

This results in the Caption Text on top right of each Form showing the Company Name.

This works on VB2008 Express edition.

Thanks to QamGine for his reply. His suggestion will be useful to me for other things I've no doubdt. It's in my Snippet Library.

Happy New Year to All

Steve




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top