I have a form with lets say 2 textboxes; textbox x and textbox y
the thing is I want b4ppc to check if in one of them is text typed in (only ok when OR x OR y is typed in, not ok when x AND y are typed in or if nothing is typed in).
I thought i could use:
If x.text="" OR y.text="" Then
Msgbox("Please fill in x or y")
Return
End If
Thanks!
Jorrit
I would think you are right. It works better. The problem is bigger:
i have more then two lines which can be filled in:
x.text, y.text and z.text
If I use the AND argument
IF x.text="" AND y.text="" AND z.text="" my program will accept only when one is filled in (and that's what I want!), but also if i fill in all three (and that's what I don't want). My problem is therfore: how do I make my program that it will accept only and filled (x or y or z)?
Maybe I can do something like add the text from x+y+z and compare that with ""?
I think that's they way, but I don't know how to compare them. I tried this but it's not working:
Can I make a new variable and then
compare=x.text+y.text+z.text
if compare ="" then
etc. etc.
if the textboxes have similar names with different numbers like textbox1, textbox2, etc. you can cycle through the textboxes with the control statement.
I add a small example for this. Maybe it's a possible solution for you.
It will be very efficient for at least one program of mine if there is a way to group together several controls (mainly textboxes) and perform operations on all of them using one command, for example - change the color of all the textboxes in the group, or like in this thread - check if the text is null.
Of course, using the control method is possible but then I loose the textboxes specific names and programming becomes much more difficult then it is now...
Of course, using the control method is possible but then I loose the textboxes specific names and programming becomes much more difficult then it is now...
For i = 0 to x
Control(boxes(i)).Color = RGB(0,0,0)
Next
Note the present of an array index and the RGB function compared to your line of code.
EDIT:- I think I now see what you meant. You can't reference an entire array "in bulk", you need to iterate over it. If you look at my post suggesting this there is an index i for the array - I left out the For ... Next thinking it was obvious - Sorry!
Not using RGB is a syntax hangover from early versions and will not work with the next version of the compiler. Also if you use that synax in Globals it can mess up initialisation of other variables as we found out yesterday in another thread so I would advise using RGB.
"When you need to reference an entire array (not one item in the array) write the array's name followed by ()."
That is technically correct but rather obscure. To reference something means to make a pointer to it or take its' address. B4PPC cannot itself work directly with references but it can pass them to a library. So the syntax without an index would be used like this :-
SomeLibraryFunction( somearray() )
Would pass a reference to the array so within the library elements of the array could be accessed by array(somevariable).