ERROR:Message

cdeane

Member
I get:
(Input string was not in the correct format)
In optimized compilation


When I use:
B4X:
Sub InitializeConfigLine
 If TextBoxGusset.Text <0 Then
 TextBoxLayflat2.Text=TextBoxWidth.Text
LabelYeild2.BringToFront
TextBoxYeild.BringToFront 
ImageButtonConfig.Text=TextBoxWidth.Text &"x"& TextBoxMillage.Text
Panel20.BringToFront
Else If TextBoxLayflat2.Text=TextBoxWidth.Text+TextBoxGusset.Text
 TextBoxNip.Text=Table2.Cell("nip",0)/2
 TextBoxCenter.Text=TextBoxWidth.Text-TextBoxGusset.Text
 TextBoxNipToCenter.Text=TextBoxNip.Text-TextBoxCenter.Text/2
 TextBoxLeftGusset.Text=TextBoxGusset.Text/2
 TextBoxRightGusset.Text=TextBoxGusset.Text/2
 ImageButtonGussetConfig.Text=TextBoxLeftGusset.Text &"  /  "& TextBoxCenter.Text &"  /  "& TextBoxRightGusset.Text
 ImageButtonCenterToNip.Text="->  "& TextBoxNipToCenter.Text &"  <-"
 Panel2Back.BringToFront
 Panel19.BringToFront
  LabelLayflat2.BringToFront
TextBoxLayflat2.BringToFront
ImageButtonConfig.Text=TextBoxWidth.Text &"x"& TextBoxGusset.Text &"x"& TextBoxMillage.Text
PanelLowerFormCoverGusset.BringToFront
 End If
 
 TextBoxYeild.Text=TextBoxLayflat2.Text*TextBoxMillage.Text*TextBoxDensity.Text
 TextBoxSS2.Text=TextBoxPPH.Text*Table2.Cell("sp",0)/Table2.Cell("pph",0)
 TextBox1.Text=TextBoxLayflat2.Text*.637/Table2.Cell("dia",0)
 TextBox2.Text=TextBoxLayflat2.Text/Table2.Cell("top",0)
 TextBox3.Text=TextBoxLayflat2.Text/Table2.Cell("bot",0)
 TextBoxLS2.Text=TextBoxPPH.Text/TextBoxYeild.Text/.06
 ImageButtonLine.Text="Line " & Table2.Cell("lin",0)
 Form2.Show

In line (TextBoxLayflat2.Text=TextBoxWidth.Text+TextBoxGusset.Text)
 
Last edited:

cdeane

Member
Sorry for the long delay,I had to work all this weekend.
I will attempt to add an attachment here so you can see the full affect of my application.

It runs OK in normal compilation but not in optimized compilation.In fact I could say the same for it the other way around in other aspects of the program.

When running the program you will need to know this:
1.Enter Film Spec.
Ex.(Flat)
Layflat(50)
Millage(.002)
PPH(500)

2.Select a Density.
Any will do.

3.Select a line.
1 Thru 5 will do.



View attachment 5newnew.zip
 
Last edited:

agraham

Expert
Licensed User
Longtime User
You need to ensure that all textboxes whose contents are treated as numbers need to be initialised to a valid number (probably 0) if you are optimised compiling. Whilst an empty string is treated as zero in the IDE/legacy compiler it does not convert to zero when optiised compiled and causes an error.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've found two problems:
1. You should not write statements directly after an Else keyword(in multiline If clause).
Instead of:
B4X:
 If TextBoxPPH.Text=<0 Then
       Msgbox("Must Enter PPH","ERROR:PPH",cMsgBoxOK,cMsgBoxHand)
    TextBoxPPH.Color=0,255,255
    TextBoxPPH.Focus
 Else  TextBoxPPH.Color=cWhite
You should write:
B4X:
 If TextBoxPPH.Text=<0 Then
       Msgbox("Must Enter PPH","ERROR:PPH",cMsgBoxOK,cMsgBoxHand)
    TextBoxPPH.Color=0,255,255
    TextBoxPPH.Focus
 Else  
 TextBoxPPH.Color=cWhite
2. As agraham wrote you should initialize the textbox to 0 or change the condition from:
B4X:
Sub InitializeConfigLine
If  TextBoxGusset.Text >0 Then
to
B4X:
Sub InitializeConfigLine
If TextBoxGusset.Text <> "" AND  TextBoxGusset.Text >0 Then
 

cdeane

Member
Sorry for the BUMP but how is it I can enter a 0 in a textbox at design time but it not show in that textbox in run time?


B4X:
Sub InitializeConfigLine
If TextBoxGusset.Text <> "" AND  TextBoxGusset.Text >0 Then

Im not to familiar with the AND keyword.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Sorry for the BUMP but how is it I can enter a 0 in a textbox at design time but it not show in that textbox in run time?
You can't! But why would you want to? For a numeric only testbox an entry of "0" is a perfectly good default value. You will always get an error if you treat as a number a texstbox entry that cannot be parsed as a number. For safety you should probably check textbox contents before use e.g.
B4X:
If isNumber(TextBox1.Text) = true Then
  Msgbox (TextBox1.Text * 20)
Else
  ...
End If

Hlep -> Main Help -> Keywords -> String -> IsNumber


If TextBoxGusset.Text <> "" AND TextBoxGusset.Text >0 Then
' True if textbox does not contain "" and also contains a number greater than 0. i.e not null and greater than 0.
 

cdeane

Member
Tanks for the VALUABLE lesson agraham.
That was very helpful.:)
 
Top