From ff39701b0e841035089929ab7811c7431ab9b39b Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Thu, 15 Nov 2012 11:10:24 +0100 Subject: format Basic code examples --- source/text/sbasic/shared/03102100.xhp | 55 +++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'source/text/sbasic/shared/03102100.xhp') diff --git a/source/text/sbasic/shared/03102100.xhp b/source/text/sbasic/shared/03102100.xhp index cc232caf2a..0988222ff8 100644 --- a/source/text/sbasic/shared/03102100.xhp +++ b/source/text/sbasic/shared/03102100.xhp @@ -49,12 +49,16 @@ Declares a variable or an array. If the variables are separated by commas (for example, DIM sPar1, sPar2, sPar3 AS STRING), only Variant variables can be defined. Use a separate definition line for each variable. -DIM sPar1 AS STRING -DIM sPar2 AS STRING -DIM sPar3 AS STRING + +Dim sPar1 As String +Dim sPar2 As String +Dim sPar3 As String + Dim declares local variables within subroutines. Global variables are declared with the PUBLIC or the PRIVATE statement. Syntax: -[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]] + +[ReDim]Dim VarName [(start To end)] [As VarType][, VarName2 [(start To end)] [As VarType][,...]] + Parameters: VarName: Any variable or array name. @@ -96,25 +100,28 @@ DIM text(20,2) as String REM 63 elements; form 0 to 20 level 1, from 0 to 20 level 2 and from 0 to 20 level 3. You can declare an array types as dynamic if a ReDim statement defines the number of dimensions in the subroutine or the function that contains the array. Generally, you can only define an array dimension once, and you cannot modify it. Within a subroutine, you can declare an array with ReDim. You can only define dimensions with numeric expressions. This ensures that the fields are only as large as necessary. Example: -Sub ExampleDim1 -Dim sVar As String -Dim iVar As Integer -sVar = "Office" -End Sub -Sub ExampleDim2 -REM Two-dimensional data field -Dim stext(20,2) as String -Const sDim as String = " Dimension:" -for i = 0 to 20 -for ii = 0 to 2 -stext(i,ii) = str(i) & sDim & str(ii) -next ii -next i -for i = 0 to 20 -for ii = 0 to 2 -msgbox stext(i,ii) -next ii -next i -End Sub + +Sub ExampleDim1 +Dim sVar As String +Dim iVar As Integer + sVar = "Office" +End Sub + +Sub ExampleDim2 +' Two-dimensional data field +Dim stext(20,2) As String +Const sDim As String = " Dimension:" +For i = 0 To 20 + For ii = 0 To 2 + stext(i,ii) = str(i) & sDim & str(ii) + Next ii +Next i +For i = 0 To 20 + For ii = 0 To 2 + MsgBox stext(i,ii) + Next ii +Next i +End Sub + -- cgit