AdvancedHMI Software

General Category => Support Questions => Topic started by: bachphi on August 11, 2016, 03:56:45 PM

Title: Keypad and problem with Min, Max Values
Post by: bachphi on August 11, 2016, 03:56:45 PM
I tried setting up a keypad with min, max values, but it keep saying the value I entered is not within the range(92, 125), eventhough it is . I tried to add CDbl or Cint, since they are real numbers from PLC, but with the same result.
It works fine without the min, max range

Code: [Select]
Private Sub EnterTipNumber()
        Dim kpd As New MfgControl.AdvancedHMI.Controls.Keypad
        kpd.Font = New Font("Arial", 12, FontStyle.Bold)
        kpd.ForeColor = Color.AliceBlue
        kpd.Text = "Enter Tip Number:"
        kpd.MaxValue = CInt(PLC.Read("Sta0xPart.TipRange.HiLimit"))
        kpd.MinValue = CInt(PLC.Read("Sta0xPart.TipRange.LoLimit"))
        If kpd.ShowDialog = Windows.Forms.DialogResult.OK Then
            PLC.Write("Sta0xPart.TipRange.Value", kpd.Value)
        End If
    End Sub
Title: Re: Keypad and problem with Min, Max Values
Post by: bachphi on August 11, 2016, 04:33:01 PM
I directly harcoded some numbers in there ( 100, 150) and it still said number must be >100 and <150. !!

The keypad from BasicLabel seemed to work properly, but how do I bring the keypad up without actually clicking the label.
Title: Re: Keypad and problem with Min, Max Values
Post by: Archie on August 11, 2016, 09:28:39 PM
This is actually a bug in the keypad. The check works using the BasicLabel because it does not make use of the Min/Max within the keypad object. This is how the BasicLabel does the check:

                        If m_KeypadMaxValue <> m_KeypadMinValue Then
                            If KeypadPopUp.Value < m_KeypadMinValue Or KeypadPopUp.Value > m_KeypadMaxValue Then
                                System.Windows.Forms.MessageBox.Show("Value must be >" & m_KeypadMinValue & " and <" & m_KeypadMaxValue)
                                Exit Sub
                            End If
                        End If
Title: Re: Keypad and problem with Min, Max Values
Post by: bachphi on August 11, 2016, 09:36:44 PM
After scanning the label, I need to call up the keypad to enter some value. How do I call the Keypad in BasicLabel without clicking it?? Thanks Archie.
Title: Re: Keypad and problem with Min, Max Values
Post by: Archie on August 11, 2016, 09:48:55 PM
Is the scanned label going into the PC or PLC?
Title: Re: Keypad and problem with Min, Max Values
Post by: bachphi on August 11, 2016, 10:15:00 PM
It's USB scanner, so I scanned it in to PC first, validate the serial number, then pass it on to BasicLabel which go to PLC.

This is my work around:

Code: [Select]
Private Sub EnterTipNumber()
        Dim kpd As New MfgControl.AdvancedHMI.Controls.Keypad(300) 'width=300
        kpd.Font = New Font("Arial", 12, FontStyle.Bold)
        kpd.ForeColor = Color.AliceBlue
        kpd.Text = "Enter Tip Number:"
        kpd.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
        kpd.TopMost = True

        blTipRange.KeypadMaxValue = PLC.Read("Sta0xPart.TipRange.HiLimit")
        blTipRange.KeypadMinValue = PLC.Read("Sta0xPart.TipRange.LoLimit")

        If kpd.ShowDialog = Windows.Forms.DialogResult.OK Then
            If blTipRange.KeypadMaxValue <> blTipRange.KeypadMinValue AndAlso kpd.Value <> "" Then
                If kpd.Value < blTipRange.KeypadMinValue Or kpd.Value > blTipRange.KeypadMaxValue Then
                    System.Windows.Forms.MessageBox.Show("Value must be >" & blTipRange.KeypadMinValue & " and <" & blTipRange.KeypadMaxValue)
                    Exit Sub
                End If
                PLC.Write("Sta0xPart.TipRange.Value", kpd.Value)
                blTipRange.Value = kpd.Value
            End If
        End If
    End Sub
Title: Re: Keypad and problem with Min, Max Values
Post by: Archie on August 13, 2016, 09:37:15 AM
Version 3.99p will give the ability to pop up a keypad of a BasicLabel via code to make this easier.
Title: Re: Keypad and problem with Min, Max Values
Post by: bachphi on August 13, 2016, 11:00:03 PM
Thank you, Archie!