|
Public Sub LoadStringTable(jForm As Form)
Dim ctl As Control 'loop through all controls on the form For Each ctl In jForm.Controls If Len(ctl.Tag) > 0 Then Select Case Left(ctl.Name, 3) 'test name property to see what kind of 'control it is. Must use good naming conventions Case "lbl", "cmd", "fra", "opt", "chk" 'label, command button, frame, option ctl.Caption = LoadResString(ctl.Tag) ctl.ToolTipText = LoadResString(ctl.Tag + 1) Case "cbo", "lst", "txt" 'text boxtes, combo boxes, and list boxes ctl.ToolTipText = LoadResString(ctl.Tag) Case Else 'add select case statements using the 'hungarian notation of your controls End Select End If Next 'load string for form (form is not in controls collection) jForm.Caption = LoadResString(jForm.Tag) End Sub ' 'Bonus code to center form ' Public Sub CenterForm(jForm As Form) jForm.Left = (Screen.Width - jForm.Width) \ 2 jForm.Top = (Screen.Height - jForm.Height) \ 2 End Sub ' 'Place the following code in the form's code window ' Private Sub Form_Load() LoadStringTable Me CenterForm Me End Sub |