[ Pobierz całość w formacie PDF ]
.Two adjacent commas ( ,, ) mean divide expr by 1000 again.e.g.Format(1900000,"0,,") returns 2"e.g.Format(1900000,"0,,.0") returns 1.9"% percent.Insert %, multiply expr by 100 prior to formatting.: insert localized time separator152 / Chapter 8/ insert localized date separatorE+ e+ E- e- use exponential notation.Insert E (or e) and the signedexponente.g.Format(1000,"0.00E+00") returns 1.00E+03"e.g.Format(.001,"0.00E+00") returns 1.00E-03"- + $ ( ) space insert literal chare.g.Format(10,"$#") returns $10"\c insert c charactere.g.Format(19,"\####\#") returns #19# text insert literal texte.g.Format(19,"""##""###""##""") returns ##19##Example Sub MainDebug.Print Format$(2.145,"#.00") 2.15End SubFormat User-Defined TextDescription The text formats listed below can be used with the Format function.Textformats can be combined to create the user-defined text format.User-defined text formats can not be combined with other user-definedformats or with predefined formats.User-defined text formats can contain one or two sections separated by asemicolon (;)." form - format for all strings" form;nullform - nullform: format for null stringsParameter Description@ char placeholder.Insert char or space& char placeholder.Insert char or nothingall chars uppercase! fill placeholder from left-to-right (default is right-to-left)\c insert character c text insert literal textExample Sub MainDebug.Print Format( 123", ab@c") 12ab3c"Language Reference / 153 Debug.Print Format( 123", !ab@c") ab1c23"End SubFreeFile FunctionSyntax FreeFile [( )]Description Returns the next unused stream number (greater than or equal to 256).Streams 1 through 255 are private to each macro.Streams 256 through511 are shared by all macros.Example Sub MainDebug.Print FreeFile 256FN = FreeFile Open XXX For Input As #FNDebug.Print FreeFile 257Close #1Debug.Print FreeFile 256End SubFunction DefinitionSyntax [|Private|Public] _Function name [type] [([param[,.]])] [As type]statementsEnd FunctionDescription This user-defined function defines a set of statements to be executedwhen the function is called.The values of the calling arglist are assignedto the params.Assigning to name[type] sets the value of the functionresult.Public is assumed if neither Private or Public is specified.See also Declare, Property, SubExample Function Power(X,Y)P = 1For I = 1 To YP = P*XNext IPower = PEnd Function154 / Chapter 8Sub MainDebug.Print Power(2,8) 256End SubGet InstructionSyntax Get StreamNum, [RecordNum], varDescription Gets the value of a variable from StreamNum.Parameter DescriptionStreamNum Streams 1 through 255 are private to each macro.Streams 256through 511 are shared by all macros.RecordNum The record number for Random-mode files.The first record is 1.Otherwise, it is the byte position.The first byte is 1.If this isomitted, then the current position (or record number) is used.var This variable value is read from the file.For a fixed-length variable(such as Long), the number of bytes required to restore thevariable are read.For a Variant variable, two bytes whichdescribe the variable s type are read and then the variable valueis read accordingly.For a usertype variable, each field is read insequence.For an array variable, each element is read insequence.For a dynamic-array variable, the number ofdimensions and the range of each dimension is read prior toreading the array values.All binary data values are read from thefile in little-endian format.Note: When reading a string (or dynamic array) from a binary-modefile, the length (or array dimension) information is not read.The currentstring length determines how much string data is read.The current arraydimension determines how many array elements are read.See also Open, PutExample Sub MainDim V As VariantOpen SAVE_V.DAT For Binary Access Read As #1 Get #1, , VClose #1End SubLanguage Reference / 155GetAllSettings FunctionSyntax GetAllSettings(AppName$, Section$, Key$)Description Gets all of Section s settings in project AppName.Settings are returned ina Variant.Empty is returned if there are no keys in the section.Otherwise, the Variant contains a two-dimension array: (I,0) is the key,and (I,1) is the setting.Win16 and Win32s store settings in an INI filenamed AppName.Win32 stores settings in the registration database.Parameter DescriptionAppName$ This string value is the name of the project which has this Sectionand Key.Section$ This string value is the name of the section of the project settings.Example Sub MainSaveSetting MyApp ,"Font","Size",10SaveSetting MyApp ,"Font","Name","Courier"Settings = GetAllSettings( MyApp ,"Font")For I = LBound(Settings) To UBound(Settings)Debug.Print Settings(I,0); = ; Settings(I,1)Next IDeleteSetting MyApp ,"Font"End SubGetAttr FunctionSyntax GetAttr (Name$)Description Returns the attributes for file Name$.If no such file exists, a runtimeerror occurs.Parameter DescriptionName$ This string value is the path and name of the file.A path relativeto the current directory can be used.Example Sub MainF$ = Dir$( *.* )While F$ Debug
[ Pobierz całość w formacie PDF ]