如果声名一个变量为控件,能使用DataSource方法吗?比如Dim a As TextBox
Set a.DataSource = Adodc
A.DataField = "产品表"
为什么一直提示变量为设置?

解决方案 »

  1.   

    TextBox未设置啊,不存在这个控件的实例~
      

  2.   

    可以使其等于一个现存的TextBox,但不可能凭空出来一个TextBox的
    Dim a As TextBox
    set a = TextBox1'TextBox1是放在窗体上的TextBox但这样对a操作就是对TextBox1操作动态添加控件可用控件数组~
      

  3.   

    Form1.Controls.Add "VB.TextBox", "a"
       With Form1!a
          .Visible = True
          .Width = 100
          .Height = 20
          .Top = 10
          .Left = 10
       End With
      

  4.   

    这样,呵呵
        Dim a As TextBox
        Form1.Controls.Add "VB.TextBox", "t1"
        Set a = Form1.Controls("t1")
        With a
            .Visible = True
            .Width = 100
            .Height = 20
            .Top = 10
            .Left = 10
        End With
      

  5.   

    Dim a As TextBox 试试改成这样吧.
    Dim a As new TextBox
      

  6.   

    dim a as string
    a = "Textbox"
    Controls(a).DataSource = Adodc
      

  7.   

    Dim a As TextBox
    Set a = New TextBox  '---------------加上这一行
    Set a.DataSource = Adodc
    a.DataField = "产品表"
      

  8.   

    楼上
    textbox 不能NEW 的,切记切记
    dim a as textbox 
    set a = Form1.Controls.Add ("VB.TextBox", "txtA")
    a.move 100,200,3000,300
    a.visiable=true
    你就这样做吧还有,你还是不要用ADODC 吧,用ADO,方便!