Author Topic: Keypad and problem with Min, Max Values  (Read 1458 times)

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Keypad and problem with Min, Max Values
« 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
« Last Edit: August 11, 2016, 04:14:39 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Keypad and problem with Min, Max Values
« Reply #1 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.
« Last Edit: August 11, 2016, 06:16:45 PM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: Keypad and problem with Min, Max Values
« Reply #2 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

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Keypad and problem with Min, Max Values
« Reply #3 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.
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: Keypad and problem with Min, Max Values
« Reply #4 on: August 11, 2016, 09:48:55 PM »
Is the scanned label going into the PC or PLC?

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Keypad and problem with Min, Max Values
« Reply #5 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
« Last Edit: August 16, 2016, 11:08:21 AM by bachphi »
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5268
    • View Profile
    • AdvancedHMI
Re: Keypad and problem with Min, Max Values
« Reply #6 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.

bachphi

  • Hero Member
  • *****
  • Posts: 642
    • View Profile
Re: Keypad and problem with Min, Max Values
« Reply #7 on: August 13, 2016, 11:00:03 PM »
Thank you, Archie!
===================================================
This is NOT alt.read.my.mind.
No such thing is sh^t-for-brains unless you are posting to alt.read.my.mind.
===================================================