Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
InForm-PE
(06-19-2025, 10:14 PM)TempodiBasic Wrote:
  1. the first issue is that you have a duplicate of many ID of controls! This is an issue coming out when you edit a previous form in UEditor
  2. the second issue is that you have typed wrong the formula for calculating txtErgebnis
Yes, I noticed that too and wondered where it came from. Thanks! I think it's a bug in InForm.

I have a bit of trouble with calculations in InForm; the introduction isn't much help either. It's unnecessarily complicated, but that's how it was programmed, and switching to the way it's handled in VB would be too much work.
In VB, they're all text fields, and numbers are simply preceded by a VAL, nice simple  Wink

Code: (Select All)

Kolbenhub = Val(txtHub.Text)
  Drehzahl = Val(txtDrehzahl.Text)
  Kolbengeschwindigkeit = (((2 * Kolbenhub) * Drehzahl) / (60 * 100))

  txtKolbenges.Text = Format$(Kolbengeschwindigkeit, "###.00")
Reply
As soon as one edit or change something in the editor, everything duplicates again. This is clearly a bug.

After everything is corrected, there is no error message, but the result is still not displayed. I tried to consider the error messages, but there's no OK.
Code: (Select All)

    Case cmdBeendenBT
      If Control(numKolbenhub).Value <> 0 Then
        Text(txtErgebnis) = __UI_StrUsing$("###.##", ((2 * (Control(numKolbenhub).Value) * Control(numDrehzahl).Value) / 60 * 100))
      End If
      'Formel: kolbenges = (((2 * kolbenhub) * drehzahl) / (60 * 100))


Everything duplicates again.
Reply
Here a link to an example that uses Numeric Textboxes.
It seems working
4Operation BASIC calculator with NumericTextBox
Reply
@KernelPanic
about 
Quote:Text(txtErgebnis) = __UI_StrUsing$("###.##",
this doesn't work because it is a NumericTextBox (NTB) so (the control)  it accepts only numeric values...
Yes you can read the value from string Text(ControlID) but it cannot be set until it is NTB
in the meanwhile you can read the value of control  from Control(ControlID).Value and you can set it assigning a numeric value.

A little Hacking would be to transform in the code  the NTB (Numeric TextBox) into TB (TextBox) but I cannot imagine why I design a NTB and then  I convert it into a TB for assigning a value via Text(ControlID). In this case, if I prefer, I design a TB for using as numeric input box.
Reply
Yes, I also remembered the string box thing, and I turned it into a numeric box - but it didn't help.
I've done it again now, looked at the linked examples... and spent over an hour trying to disable the error messages. Without any positive results.

Maybe I have discovered another error; see screenshot. The calculation routine was inserted now into Exit (Beenden).  Huh
And of course, everything was duplicated again.

So, I am fed up at the moment. I think there's a lot wrong.  Sad

Incorrect insertion

Insertion corrected
Reply
Hi Kernelpanic
maybe we have lost in translations
in the 2 screenshots that you have posted above in your post #115 I see that you are trying to assign something_that_is_more_than_a_digit to a digit!
Control(numErgebnis).value is a number whose edge have been set at design time.
I think  that 
Code: (Select All)
 Number = "###.##", Numeric_formula   '<--- wrong syntax
Number = ("###.##", Numeric_Formula)   '<--- wrong syntax
Number = Numeric_Formula '<-- correct syntax
you can substitute Number with Control(numErgebnis).Value  and Numeric_Formula with ((2 * (Control(numKolbenhub).Value) * Control(numDrehzahl).Value) / 60 * 100) but we cannot assign something else than a number to a number variable.

if your goal is to get back from the formula a number that has the format ###.##, I think you must do this by code. and show it in a string.
So it is useful to use for result a Label at the place of the third textbox that will be never used as input tool. 
But if you like to use a textbox please make calculation before , then convert your result to a string with the right kind of output and at the end assign this last string to the textbox string.
Remember that surely there are some inner checks about the controls that are invisible to the user.
Reply
I hope this example can be useful!
calculation made by converting Text from textBoxes
Reply
I just want to recreate in InForm what I did in QB64.  Wink

Code: (Select All)

'Kolbengeschwindigkeit berechnen - 13. Juni 2024

Screen _NewImage(650, 420, 32)
$Color:32

Option _Explicit

Dim As Double kolbenhub, drehzahl, kolbenges
Dim As Long Bild, myFont
Dim As String Text

Bild = _LoadImage("..\..\Bilder\Zweitackter.gif") 'Siehe Hinweis unten um das Bild zu erhalten
_PutImage (470, 35), Bild 'Platzierung des Bildes. Haengt von der Fenstergroesse ab

Locate 2, 3
Print "Berechnung der Kolbengeschwindigkeit"
Locate 3, 3
Print "===================================="

'Bild = _LoadImage("..\..\Bilder\Zweitackter.gif") 'Siehe Hinweis unten um das Bild zu erhalten
'_PutImage (140, 15), Bild 'Platzierung des Bildes. Haengt von der Fenstergroesse ab

Locate 5, 3
Input "Kolbenhub in cm                      : ", kolbenhub
Locate 6, 3
Input "Motordrehzahl hoechste Leistung U/min: ", drehzahl

'Formel fuer die Kolbengeschwindigkeit
kolbenges = (((2 * kolbenhub) * drehzahl) / (60 * 100))

If kolbenges <= 21 Then
  Locate 8, 3
  Print Using "Die Kolbengeschwindigkeit betraegt  : ##.## m/sec"; kolbenges
Else
  Locate 8, 3
  Beep: Color Red, 0
  Print Using "Die Kolbengeschwindigkeit liegt ueber 21 m/sec: ##.##"; kolbenges
  Locate 9, 3
  Color White, 0
  Print "(Bei Dauerbelastung droht Gefahr fuer den Motor!)"
End If

Text = "Bild von A. Schierwagen, GNU-Lizens - Wikipedia"
myFont = _LoadFont("C:\Windows\Fonts\Dauphinn.ttf", 15, "")
_Font myFont

'Neue Farbe setzen
Color _RGB32(255, 165, 0), _RGB32(0, 0, 0)

'Spalte - Zeile (Umgekehrt wie bei Locate)
_PrintString (360, 340), Text

'Farbe und Schrift zuruecksetzen
Color _RGB32(255), _RGB32(0, 0, 0)
_Font 16
_FreeFont myFont

End

[Image: Kolbengeschwindigkeit2025-06-25.jpg]
Reply
@KernelPanic
I confirm that it works as I said you at post #114
However I send you this, with your form and the code to let work it!

As demo you can use the button on the right to set Input into Numeric Text boxes , the first two form the top of form.
Please use the left button to make calculation and to get into the third Numeric Text Box the result.
As you can see it is correct and is the same of your example that you were translating into Inform_Pe version.
Moreover use the middle button if you can see how hacking the third textbox from the top! As you can see the button when pressed change the nature of the Textbox switching from NumericTextBox to TextBox and viceversa... at the same moment the calculation must use the numeric data for NTB and string data from TB.
If you want to limit the number of digits before and after the point, you must transform the result and then you must assign it to NumericTextBox/TextBox.
(just as example in TB mode you can use LEFT$ for getting the last 5 digit on the left, while in NTB mode you can use CSNG)
You needn't Inform library files cause you have Inform on your PC!


Attached Files
.7z   Kolbengeschwindigkeit.7z (Size: 46.05 KB / Downloads: 70)
Reply
@TempodiBasic, thanks for your effort. It doesn't work. I've tried it all over again, but at best I get a program that doesn't display an error message, but also doesn't produce any results. It's a real shame.

I created the whole thing in VB today, see screenshot, and I like the design better in InForm than in VB. It has potential as a VB replacement, if it weren't so complicated.

Here's the source code in VB:
Code: (Select All)

'Kolbengeschwindigkeit berechnen - 26. Juni 2025

Option Explicit

Private Sub cmdBeenden_Click()
  End
End Sub

Private Sub cmdBerechnen_Click()

  Dim Kolbenhub, Drehzahl As Double
  Dim Kolbenges As Double
 
  Kolbenhub = Val(txtKolbenhub.Text)
  Drehzahl = Val(txtDrehzahl.Text)
 
  Kolbenges = (((2 * Kolbenhub) * Drehzahl) / (60 * 100))
  txtKolbenges.Text = Format$(Kolbenges, "##.##")
End Sub

Private Sub cmdLoeschen_Click()
  txtKolbenhub = ""
  txtDrehzahl = ""
  txtKolbenges = ""
End Sub

[Image: Kolben-Ges-In-Form-VB.jpg]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)