VB.net, S7Prosim and PLCSIM communication

S

Thread Starter

superbmz

Hi,

can some one give me a sample (also simple) code in VB.net to read/write in PLCSIM tags.

I am beginner in VB programming and need some help :D. I will be thankful !!!
 
Hi,

A note from your friendly local moderator here:

> can some one give me a sample (also simple) code in VB.net to read/write in PLCSIM tags.

We get a great number of messages to this forum from people asking for code of one kind or another. I have noticed that the ones who get help often provide two things:

1. details about the project they are working on.

2. Explain what they have done on their own to try and solve the problem, including a copy of the code they have created so far.

Regards,
Peg Ferraro
 
hello,

I am trying to control PLCSim variables using VB.net application, so I can easily test if my S7 programs are working fine or not. I can read/write mementos but when dealing with digital input/output it doesn't work. this is my code:<pre>
Option Explicit On
Public Class Form1
Private WithEvents S7ProSim1 As S7PROSIMLib.S7ProSim
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
S7ProSim1 = New S7PROSIMLib.S7ProSim
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
S7ProSim1.Connect()
S7ProSim1.SetScanMode(1)
Dim txt As String
txt = S7ProSim1.GetState()
Label1.Text = txt
Dim pData As Byte
pData = 15
S7ProSim1.WriteFlagValue(0, 0, pData)
S7ProSim1.ReadFlagValue(0, 0, 2, pData)
Label1.Text = pData
End Sub


Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim StartIndex As Long
Dim pData As Byte
StartIndex = 1
pData = 1
S7ProSim1.WriteInputImage(StartIndex, pData)
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim pData As Byte
Dim StartIndex As Long
Dim ElementsToRead As Long
StartIndex = 0
ElementsToRead = 0
S7ProSim1.ReadOutputImage(StartIndex, ElementsToRead, 2, pData)
Label2.Text = pData
End Sub
End Class</pre>
Problem is in "Buttons 6&7"
thanks!
 
Top