×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

VB for WinCC question

VB for WinCC question

VB for WinCC question

(OP)
Hi there,

I'm relative new to VB, I got a small problem. I'm using WinCC with VBS, it's something like VBA in excel.

I've got one variable called Dummy, this var can contain three conditions namely 1,2 and 4. If it contains 1 then a tekst (Press 3)should be displayed in var Test and so on.
In fact it's a selection of 3 radio buttons, it depends on which button is clicked which tekst should be displayed.

I wrote the following code

Sub OnLButtonDown(ByVal Item, ByVal Flags, By Val x, By Val y)

Dim dummy, Test

Set Dummy = HMIRuntime.Tags(“Dummy”)
Set Test = HMIRuntime.Tags(“Test”)

If Dummy = 1 Then Test = (“Pers3”)
    Else
        If Dummy = 2 Then Test = (“Pers4”)
        Else Test = (“Pers5”)
    End IF
End IF
End Sub

What am I doing wrong ?

RE: VB for WinCC question

First thing I notice is that you are comparing an object to a value. The Set command indicates you are setting an object. Objects can not be compared to values. You may have to access a property of the object to compare it to.

Set Dummy = ...
If Dummy = 1  - Probably causing problem

Maybe something like
Dummy.Value, Dummy.Count, ...?

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: VB for WinCC question

(OP)
DSI,

Perhaps something like

Dim Dummy
Dummy = HMIRuntime.Tags(“Dummy”).value

?

RE: VB for WinCC question

That may work.

Also, if Test is an object, you'll have to define it using the Set method.

Sub OnLButtonDown(...)

Dim dummy, Test

  Set Test = HMIRuntime.Tags(“Test”)

  Dummy = HMIRuntime.Tags(“Dummy”).value
  If Dummy = 1 Then
    Set Test = HMIRuntime.Tags(“Pers3”)
  ElseIf Dummy = 2 Then
    Set Test = HMIRuntime.Tags(“Pers4”)
  Else
    Set Test = HMIRuntime.Tags(“Pers5”)
  End IF
End Sub

Unfortunately, I don't have WinCC, so I'm just grabbing at straws.

DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.

RE: VB for WinCC question

The advice by others is absolutely correct.
You need to use the .read and .write properties as follows...


Set Dummy = HMIRuntime.Tags(“Dummy”)
Set Test = HMIRuntime.Tags(“Test”)

If Dummy.read = 1 Then Test.write = (“Pers3”)
    Else
        If Dummy.read = 2 Then Test.write = (“Pers4”)
        Else Test.write = (“Pers5”)
    End IF
End IF
End Sub


I hope that this gets you away.


Regards

Dean

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close