User Tools

Site Tools


codingfaq

Coding FAQ

Form/Control

When I create a form and I put , for example, a label control on it, how can I access to properties of this control?

There are several examples showing how to access controls. In general, it is done like in VB6.

You can access the control by using its name, e.g. you have got a Label named “Label1”.

Use “Label1” to access this control (in fact it is declared as a variable of type Label by KBasic automatically: Dim Label1 As Label)

Create a new project and a new form, add a Label to it (its name must be Label1, be sure that is correctly set) and add the following code to the form.

Sub Form_OnOpen()
  Label1.Caption = "Hello World!"
End Sub

Run the project. The caption of the Label will change at runtime.


String

How do I create a multi-line String?

Just use the alternate string quotes ”<?” and ”?>”.

  MsgBox <?
Die Welt ist groß.
Die Erde ist groß.
?>

OR

Just use the _ operator to connect several lines. To add a line feed use the constant “kbCrLf” or “Return” and connect the several strings with the & operator like in the following example.

  MsgBox "" _
& "Braucht die Welt eine Weltsprache?" _ 
& kbCrLf & "Verwirklicht Englisch den Traum von einer internationalen Sprache?" _ 
& kbCrLf & "" _ 
& kbCrLf & "Die Welt ist klein geworden im Zeitalter modernster Verkehrsmittel. Modernste Kommunikationsmittel ermöglichen schnellste Verständigung und Information rund um den Erdball. Der moderne Massentourismus führt jährlich Millionen Menschen in andere Länder. Die Wirtschaft und der Verkehr sind international verflochten. Immer mehr übernationale Organisationen entstehen. Staaten vereinigen sich zu grösseren Verbänden, wie zum Beispiel die Staaten Europas zur Europäischen Union. Die Zeit ist gekennzeichnet durch Integration. Fehlt dieser Welt, zumindest dem vereinten Europa, nicht eine gemeinsame Sprache, die nach dem Fall der Grenzbarrieren auch die Sprachbarrieren beseitigt?" _ 
& kbCrLf & "" _ 
& kbCrLf & "Oder ist diese gemeinsame Sprache als zweite für alle nicht bereits da, nämlich das Englisch? Eine deutsche Zeitung schrieb, daß über zwei Milliarden Menschen, gut ein Drittel der Erdbevölkerung, laut Schätzungen routinemässig mit der englischen Sprache in Berührung kommen. Es heißt, daß jeder vierte Erdbewohner inzwischen Englisch fliessend und kompetent spricht. Also ist die internationale Sprache da, und der Traum der Esperantisten oder der Anhänger anderer ""Welthilfssprachen"" wird durch Englisch verwirklicht? Sicher ist das Englische in unserer Zeit von grösster Bedeutung. Obige Zahlen beweisen, daß Englisch gegenwärtig die hauptsächliche Weltverkehrssprache ist und daß nicht Wirtschaft und Verkehr, sondern auch der Tourist Nutzen davon hat. Sehr warscheinlich wird Englisch die künftige ""offizielle"" zweite Sprache für alle sein." _ 
, 0, "English yes?"

Platform-specific compilation

Sometimes it might be useful to have the ability to compile code only on a specific platform, e.g. you need to access platform specific API using the DECLARE STATEMENT. To tell the compiler only to compile a source file for a specific platform use the following file endings.

  • .windows.kbasic_class
  • .mac.kbasic_class
  • .linux.kbasic_class
  • .windows.kbasic_module
  • .mac.kbasic_module
  • .linux.kbasic_module
  • .windows.kbasic
  • .mac.kbasic
  • .linux.kbasic

Anything else

codingfaq.txt · Last modified: 2013/06/04 13:11 by 84.176.13.135