English 中文(简体)
如何使用vb.net从MS Access数据库表单中查找Activex控件
原标题:
  • 时间:2008-12-11 07:07:56
  •  标签:

我正在开发一个vb.net工具,并需要从MS Access DB形式中找出Activex控件。我能够计算表单中的控件数量,但无法仅从表单中获取Activex控件。请问有没有任何想法可以实现这一点。

最佳回答

你能访问到controltype属性吗?如果可以,我不能帮助你用vb.net,但这里有一些可能有用的VBA代码。

ActiveXCount = 0
For Each ctl In Screen.ActiveForm
    If ctl.ControlType = 119 Then  Custom control 
         Debug.Print ctl.Class 
        ActiveXCount = ActiveXCount + 1
    End If
Next
问题回答

I am not sure what your are wanting is possible.
Try this: go into MS access and create new property that is the count of controls on the form. In VBA, me.Countrols.Count. Open the form using Access automation. OnFOrmLoad() write the number of controls to text file along with name of the form and then close the form. Afterwards open the text file in VB.net. It is indirect but it would work.

如何從Visual Basic .NET自動化Microsoft Access

自动化:

Dim oAccess As Access.Application

  Start a new instance of Access for Automation:
oAccess = New Access.ApplicationClass()

  Open a database in exclusive mode:
oAccess.OpenCurrentDatabase(filepath:="c:mydb.mdb", Exclusive:=True)

oAccess.DoCmd.OpenForm(FormName:="Employees")




相关问题
热门标签