3 Replies - 11055 Views - Last Post: 06 August 2009 - 08:47 PM Rate Topic: -----

#1 bcafifthindimt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-August 09

all vb6.0 builtin functions and there use

Posted 06 August 2009 - 09:22 AM

vb6.0 all builtin functions and there use in programming
Is This A Good Question/Topic? 0
  • +

Replies To: all vb6.0 builtin functions and there use

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: all vb6.0 builtin functions and there use

Posted 06 August 2009 - 09:23 AM

You're kidding right? No one is going to site here and post all that for you, try using Google. You can start at the Visual Basic 6 Resource Center
Was This Post Helpful? 0
  • +
  • -

#3 ken.hughes  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 4
  • Joined: 06-August 09

Re: all vb6.0 builtin functions and there use

Posted 06 August 2009 - 01:04 PM

View PostPsychoCoder, on 6 Aug, 2009 - 08:23 AM, said:

You're kidding right? No one is going to site here and post all that for you, try using Google. You can start at the Visual Basic 6 Resource Center


I would have done if he'd said please. :rolleyes:
Was This Post Helpful? 0
  • +
  • -

#4 ravmonster  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 162
  • Joined: 20-July 09

Re: all vb6.0 builtin functions and there use

Posted 06 August 2009 - 08:47 PM

Just For YOu!!!!

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}
\viewkind4\uc1\pard\lang3081\b\f0\fs20\'b7 / - Normal division
\par \'b7 \\ - Integer division (truncates the answer)
\par \'b7 ^ - Exponentiation operator
\par \'b7 * - Multiply
\par \'b7 + - Plus
\par \'b7 - - Minus
\par \'b7 = - Equal
\par \'b7 > - Greater Than
\par \'b7 < - Less Than
\par \'b7 <> - Not Equal
\par \'b7 >= - Greater than or equal
\par \'b7 <= - Less than or equal
\par \'b7 AND - Defines a boolean value that is the AND of two values
\par \'b7 result = expression1 AND expression2
\par \'b7 OR - Defines a boolean value that is the OR of two values
\par \'b7 result = expression1 OR expression2
\par \'b7 XOR - Defines a boolean value that is the exclusive OR of two values
\par \'b7 result = expression1 XOR expression2
\par \'b7 NOT - Defines an opposite boolean value
\par \'b7 A = NOT B
\par \'b7 EQV - Performs a logical equivalence on two expressions (result is true if both expressions are true)
\par \'b7 result = expression1 EQV expression2
\par \'b7 IMP - Performs a logical implication on two expressions
\par \'b7 result = expression1 IMP expression2
\par \'b7 IS - Determines if 2 variables reference the same object
\par \'b7 result = object1 IS object2
\par \'b7 LIKE - Determines if one string matches a pattern
\par \'b7 result = string LIKE pattern
\par \'b7 MOD - Returns the integer remainder of a division
\par \'b7 i = 27 MOD 5
\par Math
\par VB also provides built-in functions which can act on variables. Most are self-explanatory. In my experience, the VAL, RND, and ROUND functions are among the most valuable, so be sure to pay close attention to them!
\par \'b7 Round - Rounds a number to a selectable number of decimal places
\par \'b7 result = round ( tempvariable,2 )
\par \'b7 Val - Returns the numerical content of a string
\par \'b7 result = Val ("123.4")
\par \'b7 Int - Returns an integer by truncating (different than Fix)
\par \'b7 i = int ( tempvariable )
\par \'b7 Fix - Returns an integer by truncating (different than Int)
\par \'b7 i = fix ( tempvariable )
\par \'b7 Hex - Returns the hexadecimal value of any number
\par \'b7 temp$ = hex ( tempvariable )
\par \'b7 Oct - Returns the octal value of any number
\par \'b7 temp$ = oct ( tempvariable )
\par \'b7 Tan - Returns the tangent of an angle
\par \'b7 tempvariable1 = tan ( tempvariable2 )
\par \'b7 Rnd - Returns a random number between 0 and 1
\par \'b7 tempvariable1 = rnd
\par \'b7 Randomize - Initializes the Rnd function so it gives different answers each time
\par \'b7 randomize
\par \'b7 Sgn - Returns the sign of a number
\par \'b7 i = sgn ( tempvariable )
\par \'b7 Sin - Returns the sine of an angle
\par \'b7 tempvariable1 = sin ( tempvariable2 )
\par \'b7 Cos - Returns the cosine of an angle
\par \'b7 tempvariable2 = cos ( tempvariable )
\par \'b7 Abs - Converts a number to a positive value
\par \'b7 i = abs ( tempvariable )
\par \'b7 Sqr - Returns the square root of a number
\par \'b7 tempvariable1 = sqr ( tempvariable2 )
\par \'b7 Log - Returns the base 10 logarithm of a number
\par \'b7 tempvariable1 = log ( tempvariable2 )
\par \'b7 Atn - Returns the arctangent of an angle
\par \'b7 tempvariable1 = atn ( tempvariable )
\par \'b7 Partition - Sort of an oddball function but segregates values according to ranges
\par \'b7 Type Conversions - A variety of conversion functions
\par \'b7 CBool, CByte, CCur, CDate, CDbl, CDec, CInt, CLng, CSng, CStr, CVar
\par \'b7 Strings
\par In my experience these functions are used more than just about any of the other VB built-in functions. The FORMAT, MID, and INSTR functions are incredibly powerful and I use them extensively. If you don't understand what they are, they worth the time to figure out! The LEN and CHR functions are also valuable as are the variations on the trim and case functions.
\par \'b7 Left - Returns the left n characters of a string
\par \'b7 temp$ = left$ ( teststring$, 4 )
\par \'b7 Right - Returns the right n characters of a string
\par \'b7 temp$ = right$ ( teststring$, 4 )
\par \'b7 Trim - Removes leading and trailing spaces of a string
\par \'b7 temp$ = trim$ ( teststring$ )
\par \'b7 LTrim - Removes only the leading spaces of a string
\par \'b7 temp$ = ltrim$ ( teststring$ )
\par \'b7 RTrim - Removes only the trailing spaces of a string
\par \'b7 temp$ = rtrim$ ( teststring$ )
\par \'b7 UCase - Makes all characters upper case
\par \'b7 temp$ = ucase$ ( teststring$ )
\par \'b7 LCase - Makes all characters lower case
\par \'b7 temp$ = lcase$ ( teststring$ )
\par \'b7 Mid - Returns n characters from a string, starting a any position
\par \'b7 temp$ = mid$ ( teststring$, 1, 4 )
\par \'b7 Len - Returns the length of a string (how many characters it has)
\par \'b7 temp$ = len ( teststring$ )
\par \'b7 LSet - Positions a string inside another, flush to the left
\par \'b7 temp$ = lrset ( teststring$ )
\par \'b7 RSet - Positions a string inside another, flush to the right
\par \'b7 temp$ = rset$ ( teststring$ )
\par \'b7 Format - Returns a string formatted according to a user-defined format
\par \'b7 temp$ = format$ ( teststring$, "####.0" )
\par \'b7 String -
\par \'b7 temp$ = left$ ( teststring$, 4 )
\par \'b7 Chr - Returns the string representation of a number
\par \'b7 temp$ = str$ ( 32 )
\par \'b7 Asc - Returns the ASCII code of a single character
\par \'b7 temp$ = asc ( "A" )
\par \'b7 Space - Returns n spaces
\par \'b7 temp$ = space$ ( 15 )
\par \'b7 Instr - Determines if one string is found within a second string
\par \'b7 i = Instr (starthere, string1, string2)
\par \'b7 InStrRev - Determine if one string is found in a second, starting at the end
\par \'b7 i = InStrRev (string1, string2, start)
\par \'b7 StrComp - Compares two strings
\par \'b7 result = StrComp (string1, string2)
\par \'b7 StrConv - Converts the case of a string's characters
\par \'b7 StrConv (string, vbuppercase)
\par \'b7 StrReverse - Reverses character order in a string
\par \'b7 StrReverse (string1)
\par \'b7 Replace - Replaces each occurrence of a string
\par \'b7 Replace (bigstring, searchstring, replacementstring)
\par \'b7 FormatCurrency - Returns a string using a currency format
\par \'b7 FormatCurrency(var1, 2)
\par \'b7 FormatDateTime - Returns a date or time expression
\par \'b7 FormatDateTime("3/2/99",vbShortTime)
\par \'b7 FormatNumber - Returns a number formatted according to a variety of options
\par \'b7 FormatNumber(var1, 2)
\par \'b7 FormatPerCent - Returns a number formated as a percent
\par \'b7 FormatPerCent(var1, 2)
\par Arrays
\par Every programmer eventually uses arrays. Mostly they're pretty easy to understand. Take note, however, that you can resize an array with REDIM without losing the data. For details, see the PRESERVE keyword in the HELP entry on REDIM. If you use the LBound/UBound in your code instead of hard-coding the dimension of the array, you can later change the size of the array without touching your code!
\par \'b7 Option Base - Determines whether the lowest range of an array is 0 or 1
\par \'b7 option base 1
\par \'b7 Erase - Erases all values of an array
\par \'b7 erase (arrayname)
\par \'b7 Dim - Creates an array
\par \'b7 dim arrayname(25)
\par \'b7 Redim - Resets the bounds of an array (has option to save values)
\par \'b7 redim arrayname(28)
\par \'b7 UBound - Returns the upper dimension of an array
\par \'b7 i = ubound (arrayname)
\par \'b7 LBound - Returns the lower dimension of an array
\par \'b7 i = lbound (arrayname)
\par \'b7 Filter - Returns a subset of an array based on a filter
\par \'b7 Filter (inputarray, searchstring)
\par \'b7 Array - Yes, there is a function called array. It returns an array that has been filled with data from a list. It allows you to put the actual data values in the code to avoid having the user input it or to avoid having to read it from a file
\par \'b7 ArrayName = Array (10, 20, 30)
\par \'b7 Join - Concatenates strings within an array
\par File Handling (Generic)
\par While VB is working on a better approach (FileSystemObject), the built-in file handling statements are still the only way to access data other than through the VB database capabilities. Your skills in this area can make or break your ability to work with various formats. The OPEN/CLOSE statements are critical to success, but the LOF, EOF, and LEN functions are used even more often! It's also a given that you'll use the DIR function regularly.
\par \'b7 Dir - Returns a filename that matches a pattern
\par \'b7 temp$ = Dir ("*.*")
\par \'b7 CurDir - Returns the current directory
\par \'b7 temp$ = CurDir
\par \'b7 MkDir - Creates a directory
\par \'b7 mkdir ( "newdirectoryname" )
\par \'b7 ChDir - Changes the current directory to a new location
\par \'b7 chdir ( "newdirectoryname" )
\par \'b7 ChDrive - Changes the current drive
\par \'b7 ChDirve "A"
\par \'b7 RmDir - Removes the indicated directory
\par \'b7 rmdir ( "directoryname" )
\par \'b7 Freefile - Returns an unused file handle
\par \'b7 i = freefile
\par \'b7 Open - Opens a file for access, locking it from other applications
\par \'b7 open "filename" for input as #1
\par \'b7 Close - Closes a file so that other applications may access it
\par \'b7 close #1
\par \'b7 LOF - Returns the length of a file in bytes
\par \'b7 i = lof ( #1 )
\par \'b7 EOF - Returns a boolean value to indicate if the end of a file has been reached
\par \'b7 statusvariable = eof ( #1 )
\par \'b7 Name As - Renames a file
\par \'b7 name "filename1" as "filename2"
\par \'b7 Kill - Deletes a file
\par \'b7 kill "filename"
\par \'b7 Fileattr - Returns attribute information about a file
\par \'b7 i = int ( tempvariable )
\par \'b7 GetAttr - Returns attributes of a file or directory
\par \'b7 i = GetAttr("c:\\windows\\temp")
\par \'b7 SetAttr - Sets the attributes of a file
\par \'b7 SetAttr pathname, vbHidden
\par \'b7 Reset - Closes all disk files opened by the OPEN statement
\par \'b7 Reset
\par \'b7 FileDateTime - Returns data file was created or last edited
\par \'b7 FileDateTime ( filename )
\par \'b7 FileLen - Returns length of file in bytes
\par \'b7 FileLen ( filename )
\par \'b7 FileCopy - Copies a file to a new name
\par \'b7 FileCopy sourcefile, destinationfile
\par \'b7 Lock - Controls access to a part or all of a file opened by OPEN
\par \'b7 Lock #1
\par \'b7 UnLock - Restores access to a part or all of a file opended by OPEN
\par \'b7 UnLock #1
\par \'b7 Width # - Set the output line width used by the OPEN statement
\par \'b7 Width #2, 80
\par File Handling - ASCII-specific
\par While VB is working on a better approach (FileSystemObject), the built-in file handling statements are still the only way to access data outside of a data base. Your skills in this area can make or break your ability to work with various formats. The OPEN/CLOSE statements are critical to success, but the LOF, EOF, and LEN functions are necessary to build useful code.
\par \'b7 Line Input - Reads an entire line of ASCII text
\par \'b7 line input #1, tempvariable$
\par \'b7 Write - Puts data in a file, with separators for the data
\par \'b7 write #1, tempvariable$
\par \'b7 Print - Puts data in a file with no separators
\par \'b7 print #1, tempvariable$
\par \'b7 Spc - Used in a print statement to move a number of spaces
\par \'b7 Print #2, var1; spc(15); var2
\par \'b7 Tab - Used in a print statement to move to TAB locations
\par \'b7 Print #2, var1; Tab(20); var2
\par File Handling - Binary-specific
\par VB also support features which allow you to access a file on a byte-by-byte basis. The good thing about it is that you have more control, the bad thing is that you may have to write more code. Generally, a programmer will use the option (ASCII or Binary access) according to the least code he has to write. For binary access the Get/Put are equivalent to the Line Input and Print functions used in ASCII text file access. The big difference between the two is that binary access will read (Get) an exact number of bytes of data, and the reading can start at any byte within the file.
\par \'b7 Get - Reads data from a file
\par \'b7 get #1, anyvariable
\par \'b7 Put - Puts data into a file
\par \'b7 put #1, anyvariable
\par \'b7 Seek - Moves the current pointer to a defined location in a file
\par \'b7 seek #1, 26
\par \'b7 Input
\par \'b7 input #1, anyvariable
\par \'b7 Loc - Returns current position with an open file
\par \'b7 i = Loc(#2)
\par Declarations
\par I probably get more questions about the functions in this section than about any other group. In general, the concepts are pretty simple, but the details of getting it exactly right can cause even experienced programmers trouble. Focus on understanding Dim/ReDim/Public/Private/Sub/Function/Type and Set. However, they're all useful at times, so bear down and commit these to memory. I'll try to add more text and tips on these than I have on the others.
\par \'b7 Dim - Used to define a variable as a certain type
\par \'b7 i = dim i as integer, r as single
\par \'b7 You can use the Option Explicit to make sure that VB forces you to declare every variable you use. DIM is that simplest way to declare a variable
\par \'b7 ReDim - Used to change the dimensions of a dynamic array
\par \'b7 redim arrayname(37)
\par \'b7 Don't be afraid of this one. You can use ReDim to create an array whose size grows by 1 every time you want to add a number to it. Then, the UBound tells you how many numbers you've added.
\par \'b7 Static - Establishes a procedure variable which keeps its value between calls
\par \'b7 static i as integer
\par \'b7 For example, if you want to keep track of how many times you've been in a procedure, set a counter as STATIC and increment it by one for each visit to the procedure. It will never go away until the program is terminated.
\par \'b7 Public - Creates a variable which can be accessed outside its own procedure
\par \'b7 public i as integer
\par \'b7 Even if you're the only programmer writing code in your application, use of Private vs Public will help catch errors if you inadvertently try to access an out-of-scope variable
\par \'b7 Private - Creates a variable that can be read only in its own procedure or module, according to where the declaration took place.
\par \'b7 private i as integer
\par \'b7 Use this as often as possible to avoid unnecessary exposure of your variables to coding mistakes.
\par \'b7 Sub - Defines a procedure which can execute a block of code
\par \'b7 Sub NewProcedure (var1 as integer, var2 as string)
\par \'b7 Be sure to check out HELP for how to handle Sub arguments. There are more questions and mistakes made concerning the use of arguments than just about anything else I've seen.
\par \'b7 Function - Declares a procedure which can return a value
\par \'b7 Function NewFunction (var1 as integer, var2 as string) as SINGLE
\par \'b7 This is actually the most versatile of the Sub/Function procedure types. It can do anything a Sub can do as well as returning a value for use in an expression.
\par \'b7 Call - Transfers control to a Sub or Function (is optional)
\par \'b7 Call Procedure 1
\par \'b7 Since the use of CALL is optional, forget you ever saw it
\par \'b7 CallByName - Executes a method of an object or set/returns a property
\par \'b7 CallByName(form1,procedurename,vbMethod)
\par \'b7 The really cool thing about this is that you don't have to hardcode a procedure call. Just use a string variable with the name of the procedure to call.
\par \'b7 Option Explicit - Instructs VB to force an explicit declaration of all variables
\par \'b7 Option Explicit
\par \'b7 You're borderline stupid if you don't use it to catch typing errors. Set up the VB IDE to automatically include this in all projects.
\par \'b7 Option Compare - Instructs VB on how to make string comparisons
\par \'b7 Option Compare Binary
\par \'b7 This can add case-insensitivity for those times when you don't want to hard-code it
\par \'b7 Option Private - Prevents a module's content from being referenced outside a project.
\par \'b7 Option Private Module
\par \'b7 Generally doesn't apply to most VB applications. If you find a good use for it let me know.
\par \'b7 Property Get - Declares how to get the value of a property
\par \'b7 Property Get Name()
\par \'b7 You won't use this much until you get into creating classes of your own
\par \'b7 Property Let - Declares how to assign a value to a property
\par \'b7 Property Let Name()
\par \'b7 You won't use this much until you get into creating classes of your own
\par \'b7 Property Set - Declares how to set a variable reference to an object
\par \'b7 You won't use this much until you get into creating classes of your own
\par \'b7 Set - Assigns an object reference to a variable
\par \'b7 Set X = form1.txtInputFromUser
\par \'b7 Very useful for making code more readable or simply to cut down on how much typing you have to do!
\par \'b7 Let - Precedes assignment of a value to a variable
\par \'b7 Let i = 3
\par \'b7 It's optional, no one uses, so forget you ever saw it
\par \'b7 Type...End Type - Creates a user defined part type which consists of standard VB data types
\par \'b7 type anytypename
\par \'b7 one as string
\par \'b7 two as integer
\par \'b7 three as boolean
\par \'b7 End Type
\par \'b7 This is a really excellent way to keep several kinds of data under one variable name. Plus, you can PUT or GET a user-defined type with a single line of code.
\par \'b7 Const - Creates a variable whose value is fixed
\par \'b7 const anyname
\par \'b7 Basically, use this to give easy to remember names to values. For example, suppose you use the value 37.2 a lot in your code, then if you put CONST MyAge = 37.2 in your code you'll be able to insert the MyAge where the 37.2 should have gone. Easier to type and easier to read. Also, you can chane the value of the constant by changing only the declaration line of code, rather than searching out every place the value was used!
\par \'b7 Declare - Used to define a procedure that exists in another file
\par \'b7 declare functionname (arg1 as integer, arg2 as string) as integer
\par \'b7 ArrayName = Array (10, 20, 30)
\par \'b7 Implements - Specifies a class to be implemented in a module
\par \'b7 Friend - Allows procedure to be callable from modules outside the class
\par \'b7 GetObject - Return a reference to an ActiveX component
\par \'b7 CreateObject - Creates and returns a reference to an ActiveX object
\par \'b7 GetAutoServerSettings - Returns information about the state of an ActiveX component's registration.
\par \'b7 Enum - Declares a type for an enumeration
\par \'b7 Event - Declares a user-defined event
\par \'b7 TypeName - Returns the type of data in a variable
\par \'b7 VarType - Returns the type of data in a variable
\par \'b7 DefType - Sets the default data type of variables
\par \'b7 DefInt A-Z
\par \'b7 IS - A variety of data type or status checking options
\par \'b7 IsArray, IsBindable, IsBroken, IsDate, IsDirty, IsEmpty, IsError, IsMissing, IsNull, IsNumber, IsObject, IsReady, IsRootFolder
\par \'b7 Date/Time
\par \'b7 These functions are pretty self-explanatory so I've not added any extra comments to them.
\par \'b7 Date - Gets the current date
\par \'b7 Time - Gets the current time
\par \'b7 Now - Gets the current date and time
\par \'b7 Timer - Returns the number of seconds since midnight
\par \'b7 DateAdd - Adds a time interval to a date
\par \'b7 DateDiff - Returns how many time intervals there are between two dates
\par \'b7 DateSerial - Returns the month/day/year
\par \'b7 DateValue - Returns the date
\par \'b7 Year - Returns the current year
\par \'b7 Month - Returns the current month (integer)
\par \'b7 MonthName - Returns the text of the name of a month
\par \'b7 Day - Returns the current day
\par \'b7 Hour - Returns the current hour
\par \'b7 Minute - Returns the current minute
\par \'b7 Second - Returns the current second
\par \'b7 TimeSerial - Returns a date with the hour/minute/second
\par \'b7 TimeValue - Returns the time
\par \'b7 WeekDay - Returns the current day of the week (integer)
\par \'b7 WeekDayName - Returns the text of a day of the week
\par \'b7 Miscellaneous
\par \'b7 In this list you'll find some of the features of VB about which I get a lot of email questions! The MsgBox is easily the most used of the bunch. It handles all of the "Y/N" queries to your user so get to know it well. Also, the DoEvents, Shell, and Command functions are indispensable in certain occasions so make sure you know when they should be used.
\par \'b7 MsgBox - A built-in dialog box that gives a message and allows a user input
\par \'b7 i = msgbox "Read this!", vbokonly, "Test Message"
\par \'b7 DoEvents - Allows VB to complete pending tasks
\par \'b7 doevents
\par \'b7 Shell - Executes a 2nd program from within the current program
\par \'b7 shell "notepad.exe"
\par \'b7 Command - Gives any text that followed a VB .EXE execution command
\par \'b7 temp$ = command
\par \'b7 Environ - Returns the system environmental space content
\par \'b7 temp$ = environ
\par \'b7 Beep - Makes the computer beep once.
\par \'b7 beep
\par \'b7 InputBox - A built-in dialog box that allows entry of a text string
\par \'b7 inputbox "Input a value!", 5
\par \'b7 AddressOf - Provides an entry point for an external program to use a procedure
\par \'b7 AddressOf ( procedurename )
\par \'b7 AppActivate - Activates an applications window
\par \'b7 AppActivate ( windowtitle )
\par \'b7 RaiseEvent - Fires an event declared at module level
\par \'b7 RaiseEvent ProcedureName
\par \'b7 Load - Load an object
\par \'b7 load form1
\par \'b7 Unload - Unload an object
\par \'b7 Unload form1
\par \'b7 LoadPicture - Load a picture into a control property
\par \'b7 form1.picture = loadpicture (filename)
\par \'b7 SavePicture - Save a picture to a file
\par \'b7 SavePicture(form1.picture,filename)
\par \'b7 LoadResData - Load the data from a resource file
\par \'b7 LoadResData(index,format)
\par \'b7 LoadResString - Load a string from a resource file
\par \'b7 LoadResString(index,format)
\par \'b7 SendKeys - Send keys to another app as though they were from the keyboard
\par \'b7 Sendkeys \{DOWN\}
\par \'b7 QBColor - Returns a value corresponding to the original QB values 0-15
\par \'b7 form1.backcolor = QBcolor (12)
\par \'b7 RGB - Returns a color value by inputting the red, green, and blue parts
\par \'b7 form1.backcolor = RGB (12,128,256)
\par \'b7 Me - Refers to the current object, usually the active form
\par \'b7 print Me.caption
\par \'b7 Registry
\par \'b7 I've never quite understood why Microsoft got away from the use of an INI file. The ability to use a simple text editor to resolve problems with a program's settings was a key feature about INI files. Also, no matter how Windows crashed, the INI file was protected.
\par \'b7 Whining aside, VB has made it incredibly easy to access values in the registry. The following VB functions are simple to use and there's hardly any excuse for not taking advantage of them. One thing to remember is that the registry save strings so if you're saving or reading numeric information then may have to do some string manipulation with the results.
\par \'b7 GetSetting - Get a value from the Registry
\par \'b7 temp$ = getsetting "TestApp", "SectionName", "KeyName", "defaultvalue"
\par \'b7 GetAllSettings -Returns a list of key settings and their values
\par \'b7 GetAllSettings(appname,section)
\par \'b7 SaveSetting - Save a value into the Registry
\par \'b7 savesetting "TestApp", SectionName, KeyData
\par \'b7 DeleteSetting - Deletes an entry from the registry
\par \'b7 deletesetting "TestApp", "SectionName", "Keyname"
\par \'b7 Loops and Conditional Decisions
\par \'b7 While the event-driven model of VB has taken out a lot of the need for controlling the flow of your application, don't think for a second that you can get by without being an expert on these features of VB. Virtually every single procedure you'll ever write will have one or more of these in it. The concepts are simple, so take the time to become a master of each one! The For...Next and the Select Case statements are the two most used, so concentrate on them first.
\par \'b7 If..Then..Else - Performs code based on the results of a test
\par \'b7 If A>5 Then Print "A is a bit number!"
\par \'b7 For...Next - Loops a specified number of times
\par \'b7 For i = 1 to 5: print #1, i: next i
\par \'b7 For Each ... Next - Walks through a collection
\par \'b7 For Each X in Form1.controls: Next X
\par \'b7 While...Wend - Loops until an event is false
\par \'b7 while i < 5: i = i +1: wend
\par \'b7 Select Case - Takes an action based on a value of a parameter
\par \'b7 select case i
\par \'b7 case 1 : print "it was a 1"
\par \'b7 case 2 : print "it was a 2"
\par \'b7 end select
\par \'b7 Do...Loop - Loops until conditions are met
\par \'b7 do while i < 5 : i = i + 1 : loop
\par \'b7 IIF - Returns 1 of two parts, depending on the value of an expression
\par \'b7 result = IIF (testexpression, truepart, falsepart)
\par \'b7 Choose - Selects and returns a value from a list of arguments
\par \'b7 Choose (index, "answer1", "answer2", "answer3")
\par \'b7 With - Executes a series of statements on a single object
\par \'b7 With textbox1
\par \'b7 .Height = 100
\par \'b7 .Width = 500
\par \'b7 End With
\par \'b7 End - Immediately stops execution of a program
\par \'b7 End
\par \'b7 Stop - Pauses execution of a program (can restart without loss of data)
\par \'b7 Stop
\par \'b7 Switch - Returns a value associated with the first true expression in a list
\par \'b7 result = Switch (testvalue1, answer1, testvalue2, answer2)
\par \'b7 GoTo - Switches execution to a new line in the code
\par \'b7 GoTo Line1
\par \'b7 GoSub ... Return - Switches execution to a new block of code and then returns
\par \'b7 GoSub Line1
\par \'b7 On .. GoSub - Branch to a specific line of code then return at the next Return statement
\par \'b7 On Number GoSub Line1, Line2, Line3
\par \'b7 On .. GoTo - Branch to a specific line of code
\par \'b7 On Number GoTo Line1, Line2, Line3
\par \'b7 Special Values
\par \'b7 There are some keywords in VB which take on special meaning. Their use can be confusing at times, but you'll get used to the terminology as your programming experience grows.
\par \'b7 True - A logical (Boolean) expression. In VB, its value is -1
\par \'b7 X = TRUE
\par \'b7 False - A logical (Boolean expression. In VB, its value is 0
\par \'b7 X = FALSE
\par \'b7 Nothing - Disassociates an object variable from an actual object
\par \'b7 Set X = Nothing
\par \'b7 Null - Indicates that a variable has no valid data
\par \'b7 X = Null
\par \'b7 Empty - Indicates that a variable has not yet been initialized
\par \'b7 X = Empty
\par Error Handling
\par Try as I might, I cannot create error free code! So, I turn to these VB features to help me figure out what went wrong.
\par \'b7 On Error - Enables an error-handling routine
\par \'b7 On Error GoTo Line2 (if error occurs, go to line2)
\par \'b7 On Error Resume Next (if error occurs, continue executing next line of code)
\par \'b7 On Error Goto 0 (disables error handling)
\par \'b7 Resume - Used to resume execution after a error-handling routine is finished
\par \'b7 Resume
\par \'b7 Resume Next
\par \'b7 Resume Line1
\par \'b7 CVErr - Returns an error type variable containing a user-specific error number
\par \'b7 X = CVError(13)
\par \'b7 Error - Simulates the occurrence of an error
\par \'b7 Error 23
\par Financial Calculations
\par For those folks who want to use VB for performing routine investment calcuations, VB provides a variety of functions. Personally, I use them very infrequently, but I suspect they are used regularly by a lot of programmers. I've never gotten a single question in the mail about these functions!
\par \'b7 DDB - Returns the depreciation of an asset for a specific time period
\par \'b7 FV - Returns the future value of an annuity
\par \'b7 IPmt - Returns the interest payment of an investment
\par \'b7 IRR - Returns the internal rate of return on a cash flow
\par \'b7 MIRR - Returns a modified internal rate of return on a cash flow
\par \'b7 NPer - Returns a number of periods for an annuity
\par \'b7 NPV - Returns a present value of an investment
\par \'b7 PPmt - Returns the principal payment of an annuity
\par \'b7 PV - Returns the present value of an annuity
\par \'b7 Rate - Returns the interest rate per period for an annuity
\par \'b7 SLN - Returns the straight-line depreciation of an asset
\par \'b7 SYD - Returns the sum-of-years' digits depreciation of an asset
\par }

Was This Post Helpful? 1

Page 1 of 1