none
vb应用问题 RRS feed

  • 问题

  • 这是vb6的代码

    Function pangkalan()
    Data1.DatabaseName = App.Path + "\db1.mdb"
    Data1.RecordSource = "select bank,interest from bank"
    Data1.Refresh
    End Function
    Function calculate()
    
      Dim c As TextBox
      Dim zz, d As Integer
      d = Data1.Recordset.RecordCount
      
      For zz = 1 To d
        Set c = finance.Controls.Add("VB.TextBox", "Text" & zz)
        c.Text = "Text" & zz
        o = c.Text
        o = Text5.Text * Data1.Recordset![interest] / 100 * Text4.Text / 12
        c.Text = o
         Data1.Recordset.MoveNext
      Next
        Call calculateyear
    End Function
    
    Function calculateyear()
    
    
      Dim e As TextBox
      Dim i, d As Integer
      d = Data1.Recordset.RecordCount
      
      For i = 1 To d
        Set e= finance.Controls.Add("VB.TextBox", "Textbox" & i)
        d.Text = "Text" & i
        g=d.text
        k=c.text * g  ‘c.text是在function calculate,所以在calculateyear是无法引用。
        
         Data1.Recordset.MoveNext
      Next
    End Function
    
    1. c.text是在function calculate,所以在calculateyear是无法引用。该怎样写才可以引用c.text来计算k=c.text * g 。textbox的数量是根据数据库的数据来动态生成的,所以
    k=c.text 必须重复计算给每一个数据。请帮忙修改我的代码。 
    2010年10月13日 7:52

答案