[Gambas-bugtracker] Bug #1837: Crashes on start

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Sun Jul 26 12:05:38 CEST 2020


http://gambaswiki.org/bugtracker/edit?object=BUG.1837&from=L21haW4-

Comment #11 by John HODGES:

Thank you, Benoit. I can't see a way of attaching text files, so I copy & pasted the contents of the 'form' and the 'class'.

FMain.form:

--------------------------------------------

# Gambas Form File 3.0

{ Form Form
  MoveScaled(0,0,70,69)
  Background = &HFFF7DF&
  Foreground = Color.TextForeground
  ToolTip = ("Fuel consumption conversion utility")
  Text = ("Consumption Conversion")
  Resizable = False
  { Label1 Label
    MoveScaled(1,1,67,5)
    Font = Font["Liberation Sans Narrow,Bold,Underline,13"]
    Drop = True
    Expand = True
    Text = ("Consumption Conversion: MPG tp L/100km or L/100km to MPG")
    Alignment = Align.Center
  }
  { ValueBox1 ValueBox
    MoveScaled(8,35,11,3.4286)
    Font = Font["+1"]
  }
  { Label2 Label
    MoveScaled(14,18,26,4)
    Font = Font["Liberation Sans Narrow,Underline,11"]
    Text = ("MPG to L/100km Conversion:")
  }
  { Label3 Label
    MoveScaled(5,10,61,5)
    Font = Font["Liberation Sans Narrow,11"]
    Text = ("Select the required radio button, enter number of MPG or L/100km in the box \nbelow and then click the 'Calculate' button.")
    Alignment = Align.TopLeft
  }
  { Button1 Button
    MoveScaled(34,35,12,3)
    Font = Font["Liberation Sans Narrow,11"]
    Foreground = Color.TextForeground
    Text = ("Calculate")
  }
  { TextBox1 TextBox
    MoveScaled(7,46,34,4)
    Font = Font["+1"]
  }
  { Button2 Button
    MoveScaled(36,62,12,4)
    Font = Font["Liberation Sans Narrow,11"]
    ToolTip = ("Clear the fields and set all variables back to zero")
    Text = ("Reset")
  }
  { Button3 Button
    MoveScaled(54,62,12,4)
    Font = Font["Liberation Sans Narrow,11"]
    ToolTip = ("Quit the program!")
    Text = ("Exit")
  }
  { Label4 Label
    MoveScaled(14,25,26,4)
    Font = Font["Liberation Sans Narrow,Underline,11"]
    Text = ("L/100km to MPG Conversion:")
  }
  { RadioButton1 RadioButton
    MoveScaled(9,18.2857,4,4)
  }
  { RadioButton2 RadioButton
    MoveScaled(9,25.2857,4,4)
  }
}

--------------------------------------------

FMain.class:

--------------------------------------------

' Gambas class file

Public Sub _new()

End

Public Sub Form_Open()

End

Public Sub Button1_Click()  ' Calculate

  Dim ue As Float         ' user entry
  Dim g2l As Float        ' imp gallons to litres conversion
  Dim k2m As Float        ' km to miles conversion
  Dim m2k As Float        ' miles to km conversion
  Dim raw_rslt As Float   ' unrounded result
  Dim fin_rslt As Float   ' rounded result
  
'  ue = 0
'  raw_rslt = 0
'  fin_rslt = 0
'  TextBox1.Text = ""
'  ValueBox1.Value = 0
  
  ue = ValueBox1.Value    ' you enter
  g2l = 4.54609
  k2m = 1.609344
  m2k = 0.621371192
  
  If RadioButton1.Value = True Then   ' convert mpg to l/100km
    If ue = 0 Or ue < 0 Then
      Message.Warning("You must enter a value greater than zero.")
    Else
      raw_rslt = ((g2l * 100) / k2m) / ue
      fin_rslt = Round(raw_rslt, -4)
      TextBox1.Text = ue & " mpg is equal to " & fin_rslt & " l/100kms"
    Endif
  Endif
  
  If RadioButton2.Value = True Then   ' convert l/100km to mpg
    If ue = 0 Or ue < 0 Then
      Message.Warning("You must enter a value of greater than zero.")
    Else
      raw_rslt = (m2k * 100 * g2l) / ue
      fin_rslt = Round(raw_rslt, -4)
      TextBox1.Text = ue & " l/100kms is equal to " & fin_rslt & " mpg"
    Endif
  Endif
  
End

Public Sub Button3_Click()  ' Exit

  FMain.Close()

End

Public Sub Button2_Click()  ' Reset

  Dim ue As Float         ' user entry
  Dim g2l As Float        ' imp gallons to litres conversion
  Dim k2m As Float        ' km to miles conversion
  Dim m2k As Float        ' miles to km conversion
  Dim raw_rslt As Float   ' unrounded result
  Dim fin_rslt As Float   ' rounded resul
  
  ue = 0
  raw_rslt = 0
  fin_rslt = 0
  TextBox1.Text = ""
  ValueBox1.Value = 0
  RadioButton1.Value = True
  RadioButton2.Value = False
  
End

Public Sub RadioButton1_Click()
  
End

Public Sub RadioButton2_Click()
  
End

--------------------------------------------




More information about the Bugtracker mailing list