Help with code

cdeane

Member
I have four rows of text boxes(4 textboxes per row).One textbox in each row
has a value of 100 for as a defalt(will never change).
After the program runs all other textboxes will have a value from 0 to well in
the hundreds.Only one of these rows will have all the textboxes in the range
of 0 to 100.All I need is that row with the values of 0 to 100.

Here is how I would like to do it but for obvious reasons cant happen.This is were i need your help.

If textbox1.text=<100 and
textbox2.text=<100 and
textbox3.text=<100 then
Form1.Show
Else If textbox5.text=<100 and
textbox6.text=<100 and
textbox8.text=<100 then
Form.Show
Else If ect.,ect.,get the point

As you see textbox4 and textbox7 already has a defalt value of 100 so there not needed here.And I will have a form for each row to reside in(4 in total).
Ive got this part covered.Its the example sateted above that is my only draw back.
 

Cableguy

Expert
Licensed User
Longtime User
instead of nested ifs you could use case select...

Still I dont underrstand your question exactly, as your description is very complete but ab bit confusing....I guess you want to know when to show the form for the un-altered row?
 

cdeane

Member
Food for thought:It looks like this before run time.

100 0 0 0
0 100 0 0
0 0 100 0
0 0 0 100

When done it look like this:

100 47 753 301
215 100 162 650
13 6 100 40
33 15 250 100

Or this:

100 8 246 7
132 100 325 96
41 3 100 3
138 104 340 100

And so on and so on.
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Food for thought:It looks like this before run time.

100 0 0 0
0 100 0 0
0 0 100 0
0 0 0 100

When done it look like this:

100 47 753 301
215 100 162 650
13 6 100 40
33 15 250 100

Or this:

100 8 246 7
132 100 325 96
41 3 100 3
138 104 340 100

And so on and so on.

An what you what to do is to show a form acordingly to what row has all values above 100, yes?

What if two rows have their values above 100?

For the first part you can use the ensted if as they work fine with this...for the second is a bit more complicated...
basically you need to teste wich rows are above 100, and maybe the highest values?
 

cdeane

Member
Meaning only between and equal to 0 and only 100.

If you look in each example you can see it.
 

cdeane

Member
I think you mean =<100 And =>0,yes?
have you thought about having more than one row with valid result to this expression?

yes,and it works just fine until i hit my nimas 0 then it out the door
 

agraham

Expert
Licensed User
Longtime User
Does this do what you want? The textboxes are named according to their row and column. Depending upon the exact use the comparison of Text to the number 100 should probably be made a bit more rigorous by explicitly converting the text to a number rather than relying on an implicit conversion that may throw an error under some circumstances.
B4X:
Sub GetLowRow
   For Row = 1 To 2
      Count = 0
      For Col = 1 To 4
         w = "TextBox" & Row & Col
         If Control(w).Text <= 100 Then
            Count = Count + 1
         End If
      Next
      If Count = 4 Then
         Return Row
      End If
   Next
   Return -1
End Sub
 

cdeane

Member
Does this do what you want? The textboxes are named according to their row and column. Depending upon the exact use the comparison of Text to the number 100 should probably be made a bit more rigorous by explicitly converting the text to a number rather than relying on an implicit conversion that may throw an error under some circumstances.
B4X:
Sub GetLowRow
   For Row = 1 To 2
      Count = 0
      For Col = 1 To 4
         w = "TextBox" & Row & Col
         If Control(w).Text <= 100 Then
            Count = Count + 1
         End If
      Next
      If Count = 4 Then
         Return Row
      End If
   Next
   Return -1
End Sub

Ok,I think I know were this is going.It looks promising.I may need some time to to play with it.(I am new to this).I was all about spreadsheets at one time.

Thanks
 
Last edited:
Top