Sign in to follow this  
Followers 0
asterof

Unstable VBA in MS Form in Rsview32

2 posts in this topic

I have some vba code written in RSView32 talking to a PLC5 The code works, but seems unstable I have posted the code here in hopes someone can post a more compact and stable way of doing this This code is in a MS Form that is called from the RSView32 display Option Explicit Dim WithEvents value1 As Tag Dim WithEvents value2 As Tag Dim WithEvents value3 As Tag Dim WithEvents value4 As Tag Dim WithEvents value5 As Tag Dim WithEvents value6 As Tag Dim WithEvents value7 As Tag Dim WithEvents value8 As Tag Private Sub CommandButton7_Click() cntForm.Hide Unload cntForm End Sub Private Sub ResetBatch1_Click() StartMonitor value8.Value = 1 ' reset batch counter and transfer data StopMonitor End Sub Private Sub ResetBatchNoData_Click() StartMonitor value7.Value = 1 'reset batch counter no data transfer StopMonitor End Sub Private Sub ResetTotal1_Click() StartMonitor value6.Value = 1 'reset master total with transfer StopMonitor End Sub Private Sub Update_Button_Click() StartMonitor value1 = PPRbox.Text value2 = Diabox.Text value3 = GBRbox.Text StopMonitor End Sub Private Sub UserForm_Initialize() StartMonitor PPRbox.Text = value1 Diabox.Text = value2 GBRbox.Text = value3 StopMonitor End Sub Sub StartMonitor() On Error GoTo ErrHandler Set value1 = gTagDb.GetTag("Footage\PPR") Set value2 = gTagDb.GetTag("Footage\RDia") Set value3 = gTagDb.GetTag("Footage\GBR") Set value4 = gTagDb.GetTag("Footage\MZR") Set value5 = gTagDb.GetTag("Footage\BRok") Set value6 = gTagDb.GetTag("Footage\MTR") Set value7 = gTagDb.GetTag("Footage\BZR") Set value8 = gTagDb.GetTag("Footage\BMR") Exit Sub ErrHandler: MsgBox "StartMonitor " & Err.Description, vbCritical End Sub Sub StopMonitor() On Error Resume Next Set value1 = Nothing Set value2 = Nothing Set value3 = Nothing Set value4 = Nothing Set value5 = Nothing Set value6 = Nothing Set value7 = Nothing Set value8 = Nothing End Sub Private Sub eMYTag_ValueChange(NewValue As Variant) MsgBox "MyDeviceTag Value is Now " & Str(NewValue), vbOKOnly End Sub

Share this post


Link to post
Share on other sites
Without seeing the form my first guess is that your UserForm_Initialized code should be Private Sub UserForm_Initialize() StartMonitor PPRbox.Text = value1.value Diabox.Text = value2.value GBRbox.Text = value3.value StopMonitor End Sub Also, I'm not so sure you have the tag object variables value1, etc. declared correctly, but I'm not sure exactly what you are trying to accomplish so I can't say for sure. I would declare it as RSVIew32.Tag, not just tag, just to make sure you are explicitly defining it at the right kind of tag object.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0