beautypg.com

B&B Electronics MODSCAN32 - Manual User Manual

Page 83

background image

83

Command1 is used to write a data value to the slave device. The value specified by Text5 is written to the
IO Point array indexed by Text4. Again, the application must determine whether to write a coil or register
value by examininig the Address property. The control data is automatically refreshed after a write
operation so the next ready event should displaythe results of the write.


Private Sub Command1_Click()

If (Modbuss1.Address < 30000) Then

Call write_coil

Else: Call write_register

End If

End Sub


Public Sub write_coil()
Dim index, value As Integer

If (IsNumeric(Text4)) Then

index = Text4

End If

If (IsNumeric(Text5)) Then

value = Text5

End If

If ((index < 20) And (value <= 1)) Then

Modbuss1.Coil(index) = value

End If

End Sub


Public Sub write_register()
Dim index, value As Integer

If (IsNumeric(Text4)) Then

index = Text4

End If

If (IsNumeric(Text5)) Then

value = Text5

End If

If (index < 20) Then

Modbuss1.Register(index) = value

End If

End Sub