关于GetValueFromName和SetValueFromName的问题 点击:710 | 回复:3



wonisn

    
发表于:2010-03-16 10:46:52
楼主

按照《MCGS高级开发指南》的“在Visual Basic中操作MCGS”例程修改如下:

Dim DatObj As Object

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, i As Integer
     For i = 1 To 5
          msg = "Dat" + Format$(i, "00")
          DatObj.GetValueFormName msg, tt
          Text1(i) = Format$(tt)
     Next i
End Sub

Private Sub Cmd_Write_Click()
      Dim msg As String, tt As Variant, i As Integer
      For i = 1 To 5
             msg = "Dat" + Format$(i, "00")
             tt = Val(Text2(i))
             DatObj.SetValueFormName msg, tt
      Next i
End Sub

为什么当执行到下划线语句时,会发生“实时错误438  对象不支持该属性或方法”?



楼主最近还看过

SSI ļʱ