Help

Hello. My name is Brian. I am fairly new to xojo. I have a situation in which I am trying to produce a very specialized Algorithm Generator that is targeted at Rawhide, and Leather Braiders. I have images of what I’m trying to do and 1 image where I’m only half way completed.


VB 2015 Working Numbers

What I want to achieve;
https://image.ibb.co/f3xdWF/algorithm_sheet_001.jpg

Please, if there are any questions about this. Please let me know and I will do my best to answer them…

Any help and advice is greatly appreciated.
Best regards,
Brian

Are you having problems implementing your algorithm, or just with getting the results to show up where you expect them to?

The whole thing actually.

Okay. So i’ve been trying this and not getting my results txtTotal or txtRemainder. I need help with this code and what i’m doing wrong.

Code;

[code] Dim txtPartsField As String
Dim txtBightsField As String
Dim txtTotal As String
Dim txtRemainder As String
Dim txtWraps As String
Dim txtGCD As String
Dim txtHalfCycles As String

’ Math
txtTotal = Str(Val(txtPartsField) / Val(txtBightsField))
txtRemainder = Str(Val(txtPartsField) Mod Val(txtBightsField))[/code]

Brian…

I’m going to guess that txtPartsField & txtBightsField are the textfield controls on your window? In which case you should get your results by

' Math txtTotal = Str(Val(txtPartsField.text) / Val(txtBightsField.text)) txtRemainder = Str(Val(txtPartsField.text) Mod Val(txtBightsField.text))

And remove the two lines that create these properties (Dim statements) from the top of your code.

Okay. I did like you said above. Now I get this error,

What should I do?

Brian

Ok, I’m going to assume that these are also textfield controls on your window? Add .text to txtTotal & txtRemainder before the =. Unlike VB you can’t set the value of a textfield control without specifying the property - you do need to specify the text property of the class (at first I saw this as a bit of a pain, but have come to realize that strong typing should be consistent).

This what the partial interface looks like.

The text boxes to the far left are for user input. the orange colored ones are for the results.

The coding for it so far.

[code] Dim txtPartsField As String
Dim txtBightsField As String
Dim txtTotal As String
Dim txtRemainder As String
Dim txtWraps As String
Dim txtGCD As String
Dim txtHalfCycles As String

’ Math
txtTotal = Str(Val(txtPartsField) / Val(txtBightsField))
txtRemainder = Str(Val(txtPartsField) Mod Val(txtBightsField))[/code]

I’m getting no results at all.

txtTotal.text = Str(Val(txtPartsField.text) / Val(txtBightsField.text))

Ditch the variables that you don’t need. Have a look at the basic documentation how to use controls and the debugger.

which ones would you recommend?

Do what Wayne said. You need to use the names of the fields in your window, and if they’re text fields, then .text will get you the contents of those fields as strings. Eliminate these two dim statements if the fields in your window are named txtPartsField and txtBightsField:

 Dim txtPartsField As String
 Dim txtBightsField As String

Personally, I like to use Self. when referring to controls that are in the same window as the code that calls them.

For example: I use Self.txtPartsField.text, which means that “txtPartsField” is a control on the same window this code is in, and “.text” gets you the content of that control as a string.

Change by your example above. Still nothing for results.

Upload a test project. You are missing something (don’t worry, all of us have been doing that).

Where do I do that? I’m only asking for safety reasons.

Dropbox or your own website.

Here you go.

Dropbox
https://www.dropbox.com/s/01fzobvx9huesyr/Algorithm%20Generator.zip?dl=0

Don’t use the same name for both a variable and a control. This confuses Xojo.

The code in the button should ONLY be:

txtTotal.text = Str(Val(Self.txtPartsField.text) / Val(Self.txtBightsField.text)) txtRemainder.text = Str(Val(Self.txtPartsField.text) Mod Val(Self.txtBightsField.text))

and you will get NaN and 0 for the current values.

This is what I get when applying the code you suggested.

Brian…

You didn’t remove the additional variables.

Got working so far. But need help with 2 result boxes and the format.

The total comes up with a decimal like 3.25. All I need is just the whole number of 3. Plus how do I use GCD, or how to code 2 results to get the GCD result.