Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - wimsettj

Pages: [1]
1
I am getting this error "InvalidOperationException was unhandled" when switching from Form6 to my Main Form with a Form change button. It does not happen every time. Sometimes I can change 5 times in a row and other times I can't change once without the error.

My Form6 is opened by clicking any selection button on Forms 1 through 4. This action also transfers the name of the selection to a BasicLabel on From6. I don't know if the error is happening because the original form is still open in the background when I leave Form6 or if something else is going on.
This is what I'm using for Forms1-4
Code: [Select]
Public Class Form1

    Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        If components IsNot Nothing Then
            Dim drv As AdvancedHMIDrivers.IComComponent
            '*****************************
            '* Search for comm components
            '*****************************
            For i As Integer = 0 To components.Components.Count - 1
                If components.Components(i).GetType.GetInterface("AdvancedHMIDrivers.IComComponent") IsNot Nothing Then
                    drv = components.Components.Item(i)
                    '* Stop/Start polling based on form visibility
                    drv.DisableSubscriptions = Not Me.Visible
                End If
            Next
        End If
    End Sub

    Private DrinkName As String

    Private Sub LongIsland_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LongIsland.Click
        DrinkName = "Long Island"
        LoadForm6(DrinkName)
    End Sub

    Private Sub LongBeach_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LongBeach.Click
        DrinkName = "Long Beach"
        LoadForm6(DrinkName)
    End Sub
    Private Sub LoadForm6(ByVal DrinkName As String)
        Dim oForm As New Form6
        oForm.SetDrinkName = DrinkName
        oForm.Selection.Text = DrinkName
        oForm.ShowDialog()
        Me.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
I tried adding in the Me.Close() because the Form was staying open in the background but it doesn't seem to work.

My Form6 code
Code: [Select]
Public Class Form6

    Private Sub Form_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.VisibleChanged
        If components IsNot Nothing Then
            Dim drv As AdvancedHMIDrivers.IComComponent
            '*****************************
            '* Search for comm components
            '*****************************
            For i As Integer = 0 To components.Components.Count - 1
                If components.Components(i).GetType.GetInterface("AdvancedHMIDrivers.IComComponent") IsNot Nothing Then
                    drv = components.Components.Item(i)
                    '* Stop/Start polling based on form visibility
                    drv.DisableSubscriptions = Not Me.Visible
                End If
            Next
        End If
    End Sub

    Private DrinkName As String = ""

    Public WriteOnly Property SetDrinkName As String
        Set(ByVal value As String)
            DrinkName = value
        End Set
    End Property

    Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Any suggestions? I'm down to the wire on getting this project done on time.

2
Support Questions / Help getting a Basic Button to change to new Form
« on: September 23, 2014, 10:59:30 AM »
Hello everyone,

I'm still working on my automated bar & I am just about ready for full functional testing but I am having an issue with some of my VB code. Previously I used the following code to have a basic button change to form6 and transfer a string to a basic label on form6 using this code:

 Private DrinkName As String
    Private Sub LongIsland_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LongIsland.Click
        DrinkName = "Long Island"
        LoadForm6(DrinkName)
    End Sub
 Private Sub LoadForm6(ByVal DrinkName As String)
        Dim oForm As New Form6
        oForm.SetDrinkName = DrinkName
        oForm.Selection.Text = DrinkName
        oForm.ShowDialog()
    End Sub

What I want to do now is use a Basic Button on form6 to change back to my main form. I tried the code below but it does nothing when I click the button:

Private Sub LoadMain()
        Dim oForm As New Main
    End Sub
 Private Sub ReturnDrink_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReturnDrink.Click
        LoadMain()
    End Sub

I tried adding in this line:  oForm.ShowDialog() It got me to the main form when I pressed the button but then caused the form change buttons on the main form to jump back to form6 instead of going to the correct form. What have I got wrong?

3
Open Discussion / Form button visibility question
« on: June 29, 2014, 11:40:31 AM »
I'm still working on my automatic bar & I have 2 questions.

1: Is it possible to have a form button be visible/not visible based on a bit value on the PLC? The basic button has the PLCAddressVisible option, but I don't see it available for the Form button. Is there someway to do this in code?

2: Is it possible to have a basic button not visible based on 2 bit values using an OR statement like B3:0/1 OR NOT B3:0/5?

4
Open Discussion / Best way to select a drink for an automated bar
« on: April 24, 2014, 01:54:00 AM »
Archie, Thanks for this amazing HMI! It's great to see a good quality usable HMI that doesn't cost your first born child. I came across your software while looking for an HMI to use in an automated bar I am building. I am programming a SLC503 to control the drink dispensing and I am attempting to use your HMI to facilitate the drink selections.

I am new to AdvancedHMI and Visual Basic but have been working with RSLogix/Panelveiw and Wonderware HMIs for several years. I am still trying to figure out the capabilities of your HMI and VB but I am making progress. I have a question I hope you can help me with. My current plan is to use a form change button as the means to select a drink. Each drink would have its own button with the drink name on it. I've already built this much on my own.

My question is: Is it possible to use a single form as a "Drink Start/Stop" page and have each different drink selection button open this single form and transfer the drink name and some other info such as ingredients to Basic Labels and change the PLC address for the Start button to the selected drink's start bit? I know I could do this with a SuperTag in WonderWare but I'm not sure where to start with this software. How can I do this, or is there a better way?

Pages: [1]