![]() | ||
Introduction Instantiation Events & Event Handlers Global Methods & Properties | |||||||||||
File> Quit Menu Item Won't appear. After I wrote a Menu Handler, I found that when running the program, the "Quit" Menu Item (File > Quit) did not appear. After experimenting in the IDE, I selected the "Quit" Menu Item, opened its Properties Window (Window > Show Properties) and changed its SuperClass Property from "QuitMenItem" (the default) to "MenuItem"). (The Visibility Property was left at checked - the default). When running the program, the "Quit" Menu Item appeared and worked. Code in Closed Windows Won't Execute. When a window is Closed, its Source Code will not be able to be executed from then on. Eg., you have two windows (W1 & W2). W1 has two Timers: Timer1 Set to 3 secs. whose Action Event Handler Closes W1; and Timer2 Set at 5 secs. which will Show W2. W2 will never appear because the code to Show it is in W1 and W1 will have closed after 3 seconds, so destroying Timer2 (or more accurately, the Instance of a Timer Object called "Timer2" will be destroyed.) However, if Timer1 Hides W1 (does not Close it) its code will continue to be executed and therefore W2 will appear. Can't Find the Property that You Want? Some Properties of an Object are not included in its Property Window. Examples are the Top and Left Properties of a window - these can only be Set in code. Try the SuperClass of the Object (look in the Language Reference). A Property found there can be Set in code because a Property of a SuperClass is also a Property of its Objects (called "Inheritance"). An example is If EditField1.Active = True Then... Can't select a Control in a window? Sometimes, a Control in a window will obscure another Control, or a Control will disappear if (eg.,) it is given a very big Value for its Left Property. When that happens, the usual method of clicking on it to select it cannot be used. Instead, CTRL+CLICK on an empty part of the window that has no Controls in it and select the Control that you want from the contextual menu that appears. Use the Debugger It is enormously useful. Remember that it can display the Values of just about every variable etc. if you ask it to (see the manual, p 429 of V. 5.5 of RB). Another technique is write code, at a point in the program where you want to know what is going on, to produce a Message Box which displays the current value of a Variable, or the name of the Method then being executed. AE Recorder and Chasing Arrows. The AE Recorder is found by choosing Window > Show AE Recorder. Everyone agrees that this does not work. Don't waste time trying it. Also, don't waste time trying to get Chasing Arrows to work. If you have more than one window in your Project and want a particular one to open when your program runs, choose Edit > Project Settings and in the dialogue box choose the window you want. Name & Title & Caption are Different The Name of an Object is the word by which RB knows the Object. No space characters allowed. Eg., "Window1". By contrast, the Title of a window, the Caption of a Pushbutton, etc. are what appear on the screen and have no significance to RB. Don't confuse the two categories. Self-evident Names As a beginner (and indeed later) you might consider making all Object Names self-evident as to their Data Type. For example:
Infinite Undos RB offers an huge number of undos, allowing you to retrace your steps a long way back, and then you can retrace those steps forward again. Choose Edit > Undo or Edit > Redo. It has saved me many times! Edit Fields etc. It should be remembered that Edit Field, Static Text, List Box and Message Box Objects can accept Strings only - not numbers. If you want to enter numbers, enter them as a String: "56.3". To convert such a String to a proper number for use elsewhere in your program, use Val, as in GetNumber = Val(ListBox_1.List(4)), On the other hand, when writing code which will enter a number into one of these objects, convert it to a String. Use Str, as in ListBox_1.List(4) = Str(Num), where Num is a Property (Variable) of Data Type Single. (Remember, Num must have been Instantiated using the Dim Statement.) Brackets If a line of code has many confusing opening and closing brackets, it is necessary to have the same number of each. To check that, count from left to right, adding one for each opening bracket and subracting one for each closing bracket. You must end up with a total of zero at the end of the line. Comments Make sure that you add a great many comments at all points in your program, using // Comment goes here. You think that you will remember what is happening, but you are wrong. Code Snippets Below are some details of a few useful pieces, with an example of a typical Call to them. | ||
![]() | |||||||
A Call to this Method, inserted into some other code, causes a pause in the execution of that code. However, note that RB does not update its windows until execution reaches the Statement "End" in the code in the Method being Called. Therefore the following Refresh command is needed to display "One" and the Red background colour: | |||||||
EditField2.Text = "Two" End Sub | |||||||
![]() | This Function calculates the area of the specified window and Returns the result (ie., Assignes the Value of the result to the Variable to the left of the "=" Operator). Win is its Parameter and it Returns a Value of Data Type Single. Height and Width are Properties of a window. A Function is used if you mainly want to get a Value, although it can have code which causes other effects. | |||
Introduction Instantiation Events & Event Handlers Global Methods & Properties | ||