Module1 Module
The VB Application Wizard adds a module called Module1 to your project. This module contains the Sub Main startup method and will also contain the LoadResStrings method if you chose to store the project s strings in a resource file.
LoadResStrings Method
If you choose Yes when the VB Application Wizard asks if you would like to use a resource file for the strings in your application, the wizard stores strings (such as text for menu items) in a resource file. The wizard adds a method named LoadResStrings to the application to load the strings at run time. This procedure loads the strings for menu captions, ToolTips, control captions, and fonts. After the upgrade, this procedure causes 19 compile errors, mainly because it uses soft binding. The Upgrade Wizard adds an EWI to the method, advising you to replace the function with the following code supplied in Help:
Sub LoadResStrings(ByRef frm As System.Windows.Forms.Form) On Error Resume Next Dim ctl As System.Windows.Forms.Control Dim obj As Object Dim fnt As System.Drawing.Font Dim sCtlType As String Dim nVal As Short ' Set the form's caption. frm.Text = VB6.LoadResString(CShort(frm.Tag)) ' Set the font. Dim FontName As String, FontSize As Double FontName = VB6.LoadResString(20) FontSize = CShort(VB6.LoadResString(21)) frm.Font = New System.Drawing.Font(FontName, FontSize) ' Set the controls' captions using the Caption ' property for menu items and the Tag property ' for all other controls. For Each ctl In frm.Controls ctl.Font = fnt sCtlType = TypeName(ctl) If sCtlType = "Label" Then ctl.Text = VB6.LoadResString(CShort(ctl.Tag)) ElseIf sCtlType = "AxTabStrip" Then For Each obj In CObj(ctl).Tabs obj.Caption = VB6.LoadResString(CShort(obj.Tag)) obj.ToolTipText = VB6.LoadResString _ (CShort(obj.ToolTipText)) Next obj ElseIf sCtlType = "AxToolbar" Then For Each obj In CObj(ctl).Buttons obj.ToolTipText = VB6.LoadResString _ (CShort(obj.ToolTipText)) Next obj ElseIf sCtlType = "AxListView" Then For Each obj In CObj(ctl).ColumnHeaders obj.Text = VB6.LoadResString(CShort(obj.Tag)) Next obj Else nVal = 0 nVal = Val(ctl.Tag) If nVal > 0 Then ctl.Text = VB6.LoadResString(nVal) nVal = 0 nVal = Val(CObj(frm).ToolTip1.GetToolTip(ctl)) If nVal > 0 Then CObj(frm).ToolTip1.SetToolTip(ctl, VB6.Load - ResString(nVal)) End If End If Next ctl Dim mnu As System.Windows.Forms.MainMenu = CObj(frm).MainMenu1 If Not mnu Is Nothing Then LoadMenuResStrings(mnu) End If End Sub Public Sub LoadMenuResStrings(ByVal mnu As System.Windows.Forms.Menu) Dim mnuItem As System.Windows.Forms.MenuItem For Each mnuItem In mnu.MenuItems On Error Resume Next mnuItem.Text = VB6.LoadResString(CInt(mnuItem.Text)) On Error Goto 0 If mnuItem.MenuItems.Count > 0 Then LoadMenuResStrings(mnuItem) End If Next End Sub
This code is a replacement for the standard LoadResStrings method generated by the VB Application Wizard. If you haven t modified the method, simply copy and paste this procedure into your application, replacing the existing LoadResStrings method.