Private Sub Form_Load() On Error Resume Next Set DatObj = GetObject(, "McgsRun.DataCentre") If Err Then MsgBox ("请先启动MCGS运行环境!") End End If End Sub
Private Sub Cmd_Read_Click() Dim msg As String, tt As Variant For i = 1 To 10 msg = "Dat" + Format$(i, "00") DatObj.GetValueFormName msg, tt Txt(i) = Format$(tt) Next i End Sub Private Sub Cmd_Wirte_Click() Dim msg As String, tt As Variant For i = 1 To 10 msg = "Dat" + Format$(i, "00") tt = Val(Txt(i + 10)) DatObj.SetValueFormName msg, tt Next i End Sub 在Assess、Excel中都有对应的VB程序可以编程,实现对MCGS的各种操作,其方法和在Visual Basic中基本相同,可参考上面的代码进行。