Xojo Reference
| Append | Dim a() As Integer = Array(1, 3, 5, 7) a.Append 9 MsgBox Str(a(Ubound(a))) |
9 |
| Array | Dim a() As Integer = Array(1, 3, 5, 7, 9) MsgBox Str(a(2)) |
5 |
| Asc | Dim i As Integer
i = Asc("*")
MsgBox Str(i) |
42 |
| Beep | Beep |
beep one time |
| Bin | Dim s As String s = Bin(100) MsgBox s |
1100100 |
| BinaryStream.Create | Dim f As FolderItem
Dim b As BinaryStream
Dim i As UInt16 = 65535
f = GetFolderItem("sample.bin")
b = BinaryStream.Create(f, True)
b.WriteUInt16 i
b.Close |
65535 is written in |
| BinaryStream.Open | Dim f As FolderItem
Dim b As BinaryStream
Dim i As UInt16
f = GetFolderItem("sample.bin")
b = BinaryStream.Open(f, False)
i = b.ReadUInt16
b.Close |
65535 is read out |
| Bitwise | Dim i As UInt64 i = Bitwise.ShiftLeft(8, 1) MsgBox Str(i) i = Bitwise.ShiftRight(8, 1) MsgBox Str(i) |
16, 4 |
| ByRef | (1) App.Open Dim i As Integer = 3 m(i) MsgBox Str(i) m(i) MsgBox Str(i) (2) m(ByRef j As Integer) // add a shared method j = j * j |
9, 81 |
| ByVal | (1) App.Open Dim i As Integer = 3 m(i) MsgBox Str(i) m(i) MsgBox Str(i) (2) m(ByVal j As Integer) // add a shared method j = j * j |
3, 3 |
| Ceil | Dim i As Integer i = Ceil(1.234) MsgBox Str(i) |
2 |
| Chr | Dim s As String s = Chr(64) MsgBox s |
@ |
| Clipboard | Dim c As New Clipboard c.Text = "Hello World" MsgBox c.Text c.Close |
Hello World |
| Const | Const pi = 3.14 MsgBox Str(pi) |
3.14 |
| Continue | Dim i As Integer For i = 1 To 5 If i = 3 Then Continue MsgBox Str(i) Next i |
1, 2, 4, 5 |
| ConvertEncoding | Dim f As FolderItem
Dim t As TextOutputStream
Dim s As String = "posição"
f = GetFolderItem("sample.txt")
t = TextOutputStream.Create(f)
t.WriteLine s.ConvertEncoding(Encodings.UTF8)
t.Close |
"posição" is written in |
| CountFields | Dim i As Integer
i = CountFields("Real Studio Documentation", " ")
MsgBox Str(i) |
3 |
| Date | Dim d As New Date MsgBox Str(d.Year) + Str(d.Month) + Str(d.Day) |
20171226 |
| Dim | Dim i As Integer = 5 MsgBox Str(i) |
5 |
| Do | Dim i As Integer Do i = i + 1 Loop Until i > 100 MsgBox Str(i) |
101 |
| DoEvents | app.DoEvents() |
keep the app responsive |
| Encodings | Dim i As UInt16 = 22909 MsgBox Chr(i) MsgBox Encodings.UTF8.Chr(i) |
Y} (incorrect) 好 (correct) |
| Exception | Dim a(5) As Integer a(6) = 123 Exception e As RuntimeException MsgBox "continue" |
continue (build an .exe file and run) |
| Exit | Dim i As Integer For i = 1 To 10 If i > 5 Then Exit For MsgBox Str(i) Next i |
1, 2, 3, 4, 5 |
| Floor | Dim i As Integer i = Floor(1.234) MsgBox Str(i) |
1 |
| For | Dim i, j As Integer For i = 1 To 100 j = j + i Next i MsgBox Str(j) |
5050 |
| For Each | Dim a(), i, j As Integer a = Array(1, 2, 3, 4, 5) For Each i In a j = j + i Next i MsgBox Str(j) |
15 |
| Format | Dim s As String s = Format(1234.5, "\$#,###.00") MsgBox s |
$1,234.50 |
| GetFolderItem | see TextOutputStream.Create |
|
| GetOpenFolderItem | Dim t As New FileType Dim f As FolderItem t.Name = "JPEG Files" t.MacType = "JPEG" t.Extensions = ".jpg" f = GetOpenFolderItem(t) If f <> Nil Then MsgBox f.Name |
sample.jpg |
| GoTo | Dim i As Integer For i = 1 To 100 If i > 50 Then GoTo stop Next i stop: MsgBox Str(i) |
51 |
| Hex | Dim s As String s = Hex(100) MsgBox s |
64 |
| If | Dim i As Integer = 3 If i = 3 Then MsgBox "three" Else MsgBox "not three" End If |
three |
| #If | Dim s As String #If TargetWindows Then s = "W" #ElseIf TargetMacOS Then s = "M" #ElseIf TargetLinux Then s = "L" #EndIf MsgBox s |
W in Windows |
| Insert | Dim a() As String = Array("a", "b", "d")
a.Insert 2, "c"
MsgBox Str(a(2)) |
c |
| InStr | Dim i As Integer
i = InStr("Hello", "e")
MsgBox Str(i) |
2 |
| IsConnected | If System.Network.IsConnected Then MsgBox "connected" |
connected |
| IsNumeric | Dim b1, b2 As Boolean
b1 = IsNumeric("99.99")
b2 = IsNumeric("99.99USD")
MsgBox Str(b1)
MsgBox Str(b2) |
True, False |
| Join | Dim a(), s As String
a = Array("a", "b", "c")
s = Join(a, "/")
MsgBox s |
a/b/c |
| Keyboard | If Keyboard.AsyncKeyDown(&h7B) Then MsgBox "Left arrow key is pressed" End If |
Left arrow key is pressed (paste the code into TextField1.KeyDown) |
| Left | Dim s As String
s = Left("Hello World", 5)
MsgBox s |
Hello |
| Len | Dim i As Integer
i = Len("Hello World")
MsgBox Str(i) |
11 |
| Lowercase | Dim s As String
s = Lowercase("FOX")
MsgBox s |
fox |
| LTrim | Dim s As String
s = "*" + LTrim(" Hello")
MsgBox s |
*Hello |
| Max | MsgBox Str(Max(1, 2, 3, 4, 5)) |
5 |
| Mid | Dim s As String
s = Mid("Hello World", 1, 5)
MsgBox s |
Hello |
| Min | MsgBox Str(Min(1, 2, 3, 4, 5)) |
1 |
| MsgBox | MsgBox "Hello World" |
Hello World |
| Mutex | (1) App property
instance As Mutex
(2) App.Open
App.instance = New Mutex("AppName")
If Not App.instance.TryEnter Then
MsgBox "AppName is already running!"
App.instance = Nil
Quit
End If
(3) App.Close
If App.instance <> Nil Then App.instance.Leave |
AppName is already running! |
| Oct | Dim s As String s = Oct(100) MsgBox s |
144 |
| Pop | Dim a(), i As Integer a = Array(1, 3, 5, 7, 9) i = a.Pop MsgBox Str(a(Ubound(a))) |
7 |
| #Pragma | #Pragma BoundsChecking False ' a complicated array operation #Pragma BoundsChecking True |
|
| Quit | Quit |
quit the app |
| Random | Dim r As New Random MsgBox Str(r.InRange(1, 100)) |
83 |
| Redim | Dim a(10) As String Redim a(Ubound(a) + 10) MsgBox Str(Ubound(a)) |
20 |
| RegEx | Dim re As New RegEx re.SearchPattern = "<[^<>]+>" ' any character except < and > re.ReplacementPattern = "" re.Options.ReplaceAllMatches = True Dim s1 As String = "<span>Hello World</span>" Dim s2 As String = re.Replace(s1) MsgBox s2 |
Hello World |
| Rem | Dim b1, b2, b3, b4, b5 As Boolean b1 = True b2 = False b3 = b1 And b2 Rem False b4 = b1 Or b2 // True b5 = b1 Xor b2 ' True Msgbox Str(b3) + ", " +Str(b4) + ", " + Str(b5) |
False, True, True |
| Remove | Dim a() As String = Array("a", "b", "c", "d")
a.Remove 2
MsgBox Str(a(2)) |
d |
| Replace | Dim s As String
s = Replace("rabbid", "d", "t")
MsgBox s |
rabbit |
| ReplaceAll | Dim s As String
s = ReplaceAll("rappit", "p", "b")
MsgBox s |
rabbit |
| Return | (1) App.Open Dim i As Integer i = m(9) MsgBox Str(i) (2) m(j As Integer) As Integer // add a shared method Return j * j |
81 |
| Right | Dim s As String
s = Right("Hello World", 5)
MsgBox s |
World |
| Rnd | Dim d As Double d = Rnd MsgBox Str(d) |
0.6326628 |
| Round | Dim d As Double d = Round(1.7) MsgBox Str(d) |
2 |
| RTrim | Dim s As String
s = RTrim("Hello ") + "*"
MsgBox s |
Hello* |
| Select | Dim i As Integer = 3 Dim s As String Select Case i Case 1 s = "one" Case 2 s = "two" Case 3 s = "three" Else s = "greater than three" End Select MsgBox s |
three |
| ShowURL | ShowURL "http://www.xojo.com" |
launch web browser |
| Shuffle | Dim a(), i As Integer a = Array(1, 2, 3, 4, 5, 6, 7, 8, 9) a.Shuffle For i = 0 To Ubound(a) MsgBox Str(a(i)) Next i |
3, 2, 8, 9, 5, 4, 7, 1, 6 |
| Sort | Dim a(), i As Integer a = Array(9, 7, 5, 3, 1) a.Sort For i = 0 To Ubound(a) MsgBox Str(a(i)) Next i |
1, 3, 5, 7, 9 |
| Sortwith | Dim a() As Integer = Array(4, 3, 2, 1)
Dim b() As String = Array("d", "c", "b", "a")
Dim i As Integer
a.Sortwith(b)
For i = 0 To Ubound(a)
MsgBox Str(a(i)) + b(i)
Next i |
1a, 2b, 3c, 4d |
| Split | Dim a() As String
a = Split("Real Studio Documentation", " ")
MsgBox a(Ubound(a)) |
Documentation |
| Static | (1) App.Open m() m() m() (2) m() // add a shared method Static i As Integer i = i + 1 MsgBox Str(i) |
1, 2, 3 |
| Str | Dim i As Integer = 123 Dim s As String s = Str(i) MsgBox s |
123 |
| StrComp | If StrComp("FOX", "fox", 1) <> 0 Then MsgBox "not equal" |
not equal |
| TextInputStream.Open | Dim f As FolderItem
Dim t As TextInputStream
Dim s As String
f = GetFolderItem("sample.txt")
If f.Exists Then
t = TextInputStream.Open(f)
Else
Quit
End If
While Not t.EOF
s = t.ReadLine()
Wend
t.Close |
"Hello World" is read out |
| TextOutputStream.Create | Dim f As FolderItem
Dim t As TextOutputStream
f = GetFolderItem("sample.txt")
Try
t = TextOutputStream.Create(f)
Catch
Quit
End Try
t.WriteLine "Hello World"
t.Close |
"Hello World" is written in |
| Trim | Dim s As String
s = "*" + Trim(" Hello ") + "*"
MsgBox s |
*Hello* |
| Try | Dim a(5) As Integer = Array(1, 2, 3, 4, 5) Try a(6) = 6 Catch e As OutOfBoundsException MsgBox "Continue" Finally MsgBox "Continue" End Try |
Continue, Continue (build an .exe file and run) |
| Ubound | Dim a(100), i As Integer i = Ubound(a) MsgBox Str(i) |
100 |
| Uppercase | Dim s As String
s = Uppercase("fox")
MsgBox s |
FOX |
| UserCancelled | Dim i As UInt32 For i = 0 To 1000000 ProgressBar1.Value = (i / 1000000) * ProgressBar1.Maximum If i Mod 10000 = 0 Then app.DoEvents() If UserCancelled Then Exit For Next i |
press escape key to cancel |
| Val | Dim d As Double
d = Val("99.99USD")
MsgBox Str(d) |
99.99 |
| While | Dim i As Integer While i < 100 i = i + 1 Wend MsgBox Str(i) |
100 |