Solved

Default access font

Posted on 2000-05-12
10
139 Views
Last Modified: 2013-12-03
How do I set it that all my contols text boxes, command buttons, labels etc.  have times new roman 11 as a default value. At the moment every new control is tahoma 8 and I have to remember to change it each time which is getting frustrating. Thanks for any help.
0
Comment
Question by:Eamon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805330
There is a template directory in both vb5 & vb6. You can put your form there and whenever you add form to your project, you can use your 'template' form.


0
 
LVL 1

Expert Comment

by:yfang
ID: 2805344
Use control collection, similar to this:

Private Sub Command1_Click()
Dim x As Control
For Each x In Controls()
x.Font = "Courier"
Next

End Sub
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2805352
change your form's font to times new roman...and then add your controls to the form
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 28

Expert Comment

by:AzraSound
ID: 2805356
yfang...that doesnt work b/c you would have to ensure that each control in the collection has a font property...there are too many exceptions to do it that way
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 2805359
the controls, by default, take the font of their container...so by setting the form's font to what you want, every control you add after that point will take on that font property as well
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805369
What I mentioned is from the online Help and is automatic:

Templates are items that are saved in a specific directory structure in the \vb directory. They provide a way for you to re-use components and code, and to add them to projects.

When you choose the New Project command on the File menu, any projects found in the \template\projects directory appear in the New Project dialog box.

You can set the path for your template directory, or turn templates off, using the Environment tab of the Options dialog box.

0
 
LVL 1

Expert Comment

by:yfang
ID: 2805470
Using Controls collection is definately an easy solution, especially if you have lots of controls in the container already.  If you have controls that do not have the "Font" property, as AzraSound have said, it won't work. However, you can always revise your code to solve the problem.  For example, you can judge what kind of control it is first:

Private Sub Command1_Click()
Dim x As Control, mystr As String

For Each x In Controls()
If Left(x.Name, 4) = "Text" Then
' If Left(x.Name, 3)="txt" then
x.Font = "Courier"
x.FontSize = 14
End If
Next

End Sub

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2805486
ok thats assuming the control's name is Text----  something or other.  what about labels?  what about command buttons?  you have no way of knowing what the person named his/her controls. the correct way to do that is as follows for example:

For i = 0 To Controls.Count - 1
   If TypeOf Controls(i) Is Timer Then
      'do nothing
   If TypeOf Controls(i) Is CommonDialog Then
      'do nothing
   etc...

but there are just waaay too many controls to have to check so it is not a very implementable solution.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2806000
To make a change to each of the controls on a form, use this.

Dim chgControl As Control
For Each chgControl In Controls
    chgControl.Font = "Times New Roman"
Next chgControl
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2806010
ruchi please read the previous comments
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 396
Protecting vb6 & .Net code Obfuscation 18 216
VBA: loop recent folder and copy txt file. 8 56
SQL Server 2012 to SQL Server 2016 24 57
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question