ERROR:Message

Discussion in 'Questions (Windows Mobile)' started by cdeane, Jul 16, 2008.

  1. cdeane

    cdeane Member

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


    When I use:
    Code:
    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: Jul 17, 2008
  2. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that the value of both textboxes is numeric?
     
  3. cdeane

    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: Jul 20, 2008
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should include all the image files as well.
     
  5. cdeane

    cdeane Member

  6. agraham

    agraham Expert Licensed 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.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    I've found two problems:
    1. You should not write statements directly after an Else keyword(in multiline If clause).
    Instead of:
    Code:
    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:
    Code:
    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:
    Code:
    Sub InitializeConfigLine
    If  TextBoxGusset.Text >0 Then
    to
    Code:
    Sub InitializeConfigLine
    If TextBoxGusset.Text <> "" AND  TextBoxGusset.Text >0 Then
     
  8. cdeane

    cdeane Member

    I see.
    Tanks to all
     
  9. cdeane

    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?


    Code:
    Sub InitializeConfigLine
    If TextBoxGusset.Text <> "" AND  TextBoxGusset.Text >0 Then
    Im not to familiar with the AND keyword.
     
    Last edited: Jul 21, 2008
  10. agraham

    agraham Expert Licensed User

    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.
    Code:
    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.
     
  11. cdeane

    cdeane Member

    Tanks for the VALUABLE lesson agraham.
    That was very helpful.:)
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice