Re: objet automation et interfaces

Posté par clercr le 5/11/2007 9:00:05
Voici l'exemple en VB qui utilise l'interface IIIBHnet3

Dim connected As Boolean

Dim IBHNet As IIBHnet
Dim IBHNet2 As IIIBHnet2
Dim IBHNet3 As IIIBHnet3



Private Sub BTN_Read_Click()
    MW10 = IBHNet.MW(10)
End Sub

Private Sub BTN_WRITE_Click()
    IBHNet.MW(10) = MW10
End Sub

Private Sub Command3_Click()
    MD10 = IBHNet.MD(10)
End Sub

Private Sub Command4_Click()
    IBHNet.MD(10) = MD10
End Sub

Private Sub Command5_Click()
    res = IBHNet.PLC_MemFree
End Sub

Private Sub Command6_Click()
    res = IBHNet.PLC_Run
End Sub

Private Sub Command7_Click()
    IBHNet.DW(1, 0) = DB1DBW0
End Sub

Private Sub Command8_Click()
    DB1DBW0 = IBHNet.DW(1, 0)
End Sub

Private Sub Form_Load()

Set IBHNet = New IIBHnet
Set IBHNet2 = IBHNet
Set IBHNet3 = IBHNet

connected = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

Set IBHNet3 = Nothing
Set IBHNet2 = Nothing
Set IBHNet = Nothing

End Sub

Private Sub Command1_Click()

Dim ret As Long
On Error GoTo MyError
If (connected = False) Then IBHNet3.Connect_DP Text1.Text, Val(Text2.Text), 0, Val(Text3.Text)

If (ret = 0) Then
    MsgBox ("Connected" & Str(ret))
    connected = True
End If
GoTo Fin

MyError:
    MsgBox ("Fehler")
Fin:
End Sub

Private Sub Command2_Click()

If (connected = True) Then IBHNet.Disconnect
connected = False

End Sub

Private Sub Text4_Change()

End Sub




merci encore.

Attacher un fichier:



jpg  IBHTest.JPG (91.92 KB)
2964_472ecd65268c4.jpg 573X494 px

Cette contribution était de : http://old.wdforge.org/newbb/viewtopic.php?forum=18&topic_id=5477&post_id=22549