代码:Public Sub ControlsFont(ByVal frmMain As Form)
  On Error GoTo MeErr
  Dim ctl As Control
  Dim ctlName As String
  Dim strFontName As String
  Dim intFontSize As Double
'--------------------------------------------------------------------------------------------------
  strFontName = "宋体"   
  intFontSize = 10   
  frmMain.Font.Name = strFontName----这句报错
  frmMain.Font.Size = intFontSize----这句报错
  frmMain.Font.Bold = False
求各位大侠帮忙 谢谢

解决方案 »

  1.   


    Option Explicit
    Private Sub ControlsFont(ByRef objP As Control)
      Dim ctl As Control
      Dim ctlName As String
      Dim strFontName As String
      Dim intFontSize As Double
    On Error Resume Next    '忽略一些不支持字体的控件设置字体属性所产生的错误
      strFontName = "宋体"
      intFontSize = 14
        objP.Font.Size = intFontSize
        objP.Font.Name = strFontName
        objP.Font.Bold = True
    End SubPrivate Sub Form_Load()
        ControlsFont Text1
        Text1.Text = "中华人民共和国"End Sub
      

  2.   

    F8执行,执行到错误处,
    debug.print strFontName
    debug.print intFontSize 调试下这2变量的值是否正常?
    估计是变量赋值不合法。
      

  3.   

    frmMain.Font.Name = strFontName----这句报错
    frmMain.Font.Size = intFontSize----这句报错这两名写法没有问题,注掉出错处理,然后检查其它错误。
      

  4.   

    重复提问,已回复
    http://topic.csdn.net/u/20110221/19/f1b4b0c0-eeaa-4581-ba03-02b9685adc2b.html
      

  5.   

    如果窗体内都是些常规控件,可以遍历这些控件设置下属性
        Dim ctl As Control
        For Each ctl In frmMain.Controls
            ctl.Font.name=
            ctl.Font.size=
        Next