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 Create a new standard EXE project. Place controls on the form and set their properties as follows CONTROLPROPERTYVALUE Label NamelblSample Caption <blank> Tag 101 TextBoxNametxtSample Tag 103 Create a resource file. Add a second string table to see how languages work. And I know that I don't know german. Populate it with the following ID ENGLISH (UNITED STATES) GERMAN (GERMANY) 101Your Label Caption Deine Label Worde 102Your Label ToolTipText Deine Arbeitssprache 103The TextBox ToolTipText Deine arbeitsworken Add a standard module to the project and place the following code in it |