谢谢先!

解决方案 »

  1.   

    1、在工程中加个模块,模块中加入代码
    Private Sub Main()
        form2.Show
    End Sub
    需要在工程属性中设置启动对象,直接选择form2可以,选择sub main 也行2、在command1的gotfocus事件中
    Private Sub Command1_GotFocus()
        Command1.Caption = "hello"
    End Sub
      

  2.   

    谢谢大侠的答复!
    那么请问:如何在代码里面设置command1取得焦点?(而不是人工给予焦点)
    是不是command1控件的setfocus属性?但我使用command1.setfocus的时候老是报错,为什么?请教请教!
      

  3.   

    测试通过
    注意不能在form_load 事件中设置焦点
    因为在form_load过程中,控件的事件映射还没有建立,所以调用会出错
    无效的过程调用或参数Private Sub Command1_Click()
        Command2.SetFocus
    End SubPrivate Sub Command2_Click()
        Command1.SetFocus
    End Sub
      

  4.   

    Sub main()
        Form2.Show
    End SubPrivate Sub Command1_GotFocus()
       MsgBox "hello"
    End Sub
      

  5.   

    当焦点已经在command1上时,再command1.setfocus()也会出错.
      

  6.   

    为什么不在form_load事件里添加:Command1.SetFocus?
      

  7.   

    1。在工程属性中将form2设为最先运行的窗体
    2。显示在什么地方?如果在窗体上如下:Private Sub Command1_GotFocus()
        form1.print"hello"
    End Sub
      

  8.   

    Private Sub Command1_Click()
        End
    End SubPrivate Sub Form_Activate()
        Command1.Value = True
    End Sub
      

  9.   

    Private Sub Command1_GotFocus()
        Command1.Caption = "hello"
    End SubPrivate Sub Form_Load()
    Command1_GotFocus
    End Sub