Author Topic: Input string was not in correct format  (Read 1454 times)

GreatestUsernameEver

  • Newbie
  • *
  • Posts: 11
    • View Profile
Input string was not in correct format
« on: July 07, 2020, 11:30:27 AM »
Attempting to grab the text of a selected recipe and display it in a basiclabel. The issue is that when attempting to do this using code the definitions are of varying type and throws an exception even though it builds correctly and says that it is a generic function. I believe the issue is with the "item" object but not sure how to work around this.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Input string was not in correct format
« Reply #1 on: July 07, 2020, 07:42:38 PM »
You should realize that you are not providing complete information since everything indicates custom controls/code.

What is "ListButtonsEventArgs" and what is "ActiveControl"?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Input string was not in correct format
« Reply #2 on: July 07, 2020, 08:05:58 PM »
Godra... I believe he is using the RecipeSelect panel that is part of the latest beta version.

Have you tried this code:
Code: [Select]
        Label1.Text = e.ButtonText

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Input string was not in correct format
« Reply #3 on: July 07, 2020, 08:28:43 PM »
My bad ... I just tried it and Archie's code does work.

Using a BasicLabel instead of a Label could potentially overwrite the Value with the value from PLC if the PLCAddressValue property is set.

If it is for display purposes only then use a Label control instead.

« Last Edit: July 07, 2020, 08:38:25 PM by Godra »

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Input string was not in correct format
« Reply #4 on: July 07, 2020, 10:48:38 PM »
I have updated and attached the modified version of this RecipeSelect panel control.

It allows live resize and font changes in the Designer, sets the ComComponent and is also set to display "Recipe Select Panel" when control is created (instead of possibly showing the error that the ini file doesn't exist).

Apparently, using the ButtonText setting within the ini file doesn't have a function since the parser is only observing the section name.

So, this is what you might need to do:

[Recipe1]                                                                               [Lava Cake]
40001=100                            change it to                               40001=100
40002=200                                                                            40002=200
40003=300                                                                            40003=300
ButtonText=Lava Cake


And for ini file like this:

[Lava Cake]
40001=100
40002=200
40003=300
[Fruit Cake]
40001=400
40002=500
40003=600
[Cheese Cake]
40001=700
40002=800
40003=900
[Walnut Strudel]
40001=155
40002=366
40003=677
[Poppy Seed Strudel]
40001=551
40002=663
40003=776
[Pecan Strudel]
40001=355
40002=566
40003=777

you might have AHMI screen like it is in the attached picture and with the following code that retrieves the recipe name and displays it in the large label named lblCurrentRecipe:

Code: [Select]
    Private Sub RecipeSelect1_ItemSelected(sender As Object, e As Controls.ListButtonsEventArgs) Handles RecipeSelect1.ItemSelected
        lblCurrentRecipe.Text = e.ButtonText
    End Sub

« Last Edit: July 08, 2020, 07:58:01 PM by Godra »

GreatestUsernameEver

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Input string was not in correct format
« Reply #5 on: July 08, 2020, 09:10:42 AM »
The fix worked beautifully, thank you both for your assistance.