Microsoft Visual Basic 6 (ShortcutKeys and Function)
-
Upload
abdul-majeed-khan -
Category
Documents
-
view
418 -
download
0
description
Transcript of Microsoft Visual Basic 6 (ShortcutKeys and Function)
Microsoft Visual Basic Shortcut Keys and Built-in FunctionMicrosoft Visual Basic Shortcut KeysCode Window General Use KeysUse these key combinations in the Code window:Shortcut Keys DescriptionCTRL+C Copy the selected text to the Clipboard.CTRL+X Cut the selected text to the Clipboard.DELETE or DEL Delete the selected text.CTRL+V Paste the Clipboard contents at the insertion point.CTRL+Z Undo the last editing action in the current line.CTRL+DELETE Delete to the end of the word.CTRL+BACKSPACE Delete to the beginning of the word.SHIFT+TAB Remove indent.TAB Increase indent.F2 Display the object browser.F9 Set or remove a breakpoint.CTRL+SHIFT+F9 Clear all breakpoints.F5 Run an application (or continue running, if in break mode.F8 Execute code one line at a time (single step).SHIFT+F8 Execute code one procedure at a time (procedure step).CTRL+BREAK Stop running a Visual Basic application.HOME Move the cursor to the beginning of text in a line.END Move the cursor to the end of text in a line.CTRL+SPACEBAR Turn on Complete Word.CTRL+DOWN ARROW
Next procedure
CTRL+UP ARROW Previous procedureSHIFT+F2 Go to the definition of the selected procedure.CTRL+SHIFT+F2 Go to last position.
Microsoft Visual Basic Shortcut Keys and Built-in FunctionForm Window KeysUse these key combinations in the Form window:Shortcut Keys Description F7 Open the Code window for the selected object.CTRL+C Copy the selected controls to the Clipboard.CTRL+X Cut the selected controls to the Clipboard.DEL Delete the selected controls without placing them on the
Clipboard.CTRL+V Paste the Clipboard contents on the form.CTRL+Z Undo a deletion of controls.TAB Cycle forward through controls in tab order.SHIFT+TAB Cycle backward through controls in tab order.CTRL+CLICK Add or remove a control from the selection.CLICK+DRAG Select multiple controls and press Escape key to end.SHIFT+CLICK Select multiple controls on form.CTRL+E Display the Menu Editor (design time only).F4 Display the Properties window (design time only).CTRL+J Bring to front (affects overlapping controls at design time
only).CTRL+K Send to back (affects overlapping controls at design time
only).CTRL+DOWN ARROW Move the control down one grid unit.CTRL+UP ARROW Move the control up one grid unit.CTRL+RIGHT ARROW Move the control right one grid unit.CTRL+LEFT ARROW Move the control left one grid unit.Immediate Window Keyboard ShortcutsUse these key combinations in the Immediate window:Shortcuts Keys DescriptionENTER RETURN Run a line of selected code.CTRL+L Display Call Stack dialog box (break mode only).CTRL+ENTER Insert carriage return.CTRL+HOME Move the cursor to the top of the Immediate window.CTRL+END Move the cursor to the end of the Immediate window.Menu Editor KeysUse these key combinations in the Menu Editor:Shortcuts Keys DescriptionALT+R Move an item to a lower level in a hierarchical menu.ALT+L Move an item to a higher level in a hierarchical menu.ALT+U Move an item one line up.ALT+B Move an item one line down.
Microsoft Visual Basic Shortcut Keys and Built-in FunctionWatch Window Keyboard ShortcutsUse these key combinations in the Watch window:Shortcuts Keys DescriptionSHIFT+ENTER Display the selected watch expression.CTRL+W Display Edit Watch dialog box.ENTER Expands or collapses the selected watch value if it has a plus
(+) or minus (-) to the left of it.
Microsoft Visual Basic Functions
Microsoft Visual Basic String-Handling Functions
Function: Len(string)
Description: Returns a Long containing the length of the specified string
Example: lngLen = Len("Visual Basic") ' lngLen = 12
Function: Mid(string, start[, length])
Description: Returns a substring containing a specified number of characters from a string.
Example: strSubstr = Mid$("Visual Basic", 3, 4) ' strSubstr = "sual"strTest = "Visual Basic"Mid(strTest, 3, 4) = "0000" ‘strTest=”Vi0000 Basic”
Function: Left(string, length)Description: Returns a substring containing a specified number of characters from the
beginning (left side) of a string. Example: strSubstr = Left("Visual Basic", 3) ' strSubstr = "Vis" Function: Right(string, length)Description: Returns a substring containing a specified number of characters from the
end (right side) of a string. Example: strSubstr = Right$("Visual Basic", 3) ' strSubstr = "sic" Function: UCase(string) Description: Converts all lowercase letters in a string to uppercase. Example: strNew = UCase$("Visual Basic") ' strNew = "VISUAL BASIC"
Function: LCase$(string)
Description: Converts all uppercase letters in a string to lowercase.
Example: strNew = LCase$("Visual Basic") ' strNew = "visual basic"
Function: InStr([start,] string1, string2)
Description: Returns a Long specifying the position of one string within another. The search starts either at the first character position or at the position specified by the start argument.
Examples: lngPos = Instr("Visual Basic", "a") ' lngPos = 5lngPos = Instr(6, "Visual Basic", "a") ' lngPos = 9 (starting at position 6) lngPos = Instr("Visual Basic", "A") ' lngPos = 0 (case-sensitive search)
Function: String(number, character)
Description: Returns a string containing a repeating character string of the length
Microsoft Visual Basic Shortcut Keys and Built-in Function
specified. Examples: strTest = String(5, "a") ' strTest = "aaaaa"
strTest = String(5, 97) ' strTest = "aaaaa" (97 is the ASCII code for "a")
Function: Space(number)
Description: Returns a string containing the specified number of blank spaces.
Examples: strTest = Space(5) ' strTest = " "
Function: Replace(expression, find, replacewith)
Description: Returns a string in which a specified substring has been replaced with another substring a specified number of times.
Examples: strNewDate = Replace("08/31/2001", "/", "-") ' strNewDate = "08-31-2001"
Function: StrReverse(string)
Description: Returns a string in which the character order of a specified string is reversed.
Examples: strTest = StrReverse("Visual Basic") ' strTest = "cisaB lausiV" Function: LTrim(string) Description: Removes leading blank spaces from a string.
Examples: strTest = LTrim(" Visual Basic ") ' strTest = "Visual Basic " Function: RTrim(string) Description: Removes trailing blank spaces from a string.
Examples: strTest = RTrim(" Visual Basic ") ' strTest = " Visual Basic" Function: Trim(string) Description: Removes both leading and trailing blank spaces from a string.
Examples: strTest = Trim(" Visual Basic ") ' strTest = "Visual Basic"
Function: Asc(string)
Description: Returns an Integer representing the ASCII character code corresponding to the first letter in a string.
Examples: intCode = Asc("*") ' intCode = 42intCode = Asc("ABC") ' intCode = 65
Function: Chr$(charcode)Description: Returns a string containing the character associated with the specified
character code. Examples: strChar = Chr$(65) ' strChar = "A"
Microsoft Visual Basic String-Based Functions
Function:MsgBox Message, [Buttons]+[Icon], [Title]
Description: A message box is a special form used to display a piece of information to the user. As opposed to a regular form, the user cannot type anything on the box. There are usually two kinds of dialog boxes you will create: one
Microsoft Visual Basic Shortcut Keys and Built-in Functionthat simply displays information and one that expects the user to make a decision.
Button Value DisplayvbOKOnly 0
vbOKCancel 1
vbAbortRetryIgnore 2
vbYesNoCancel 3
vbYesNo 4
vbRetryCancel 5
Icon Value DescriptionvbCritical 16
vbQuestion 32
vbExclamation 48
vbInformation 64
MsgBox function can return one of the following values:
Button Return ValuevbOK 1
vbCancel 2
vbAbort 3
vbRetry 4
vbIgnore 5
vbYes 6
vbNo 7
Examples: Private Sub Form_Load() MsgBox "Welcome to the wonderful world of Microsoft Visual Basic"End SubPrivate Sub Form_Load() MsgBox "Are you ready to exit application.", vbYesNoEnd SubPrivate Sub Form_Load() MsgBox "Are you ready to exit application.", vbYesNo Or vbQuestionEnd SubPrivate Sub cmdMsgbox_Click() Dim intResponse As Integer intReponse = MsgBox("Your printing configuration " _ & "is not fully set." & vbCrLf _ & "If you are ready to print, click" & vbCrLf & _ "(1) Yes: To print the document" & vbCrLf & _ "(2) No: To configure printing" & vbCrLf & _ "(3) Cancel: To dismiss printing", _ vbYesNoCancel + vbInformation, _
Microsoft Visual Basic Shortcut Keys and Built-in Function "Critical Information") Print intReponseEnd Sub
Function:InputBox(prompt[,title,default,x-pos,y-pos])
Description:Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a string containing the contents of the text box.
Examples: a = InputBox("Enter value", "Input Box", "", 120, 120)
Logical Functions
Function: IsEmpty(Expression)Description: The IsEmpty function check whether a field is empty or not.Examples: ?IsEmpty(sFirstName)Function: IsNull(Expression)Description: To check whether an expression or the value of a control is null.Examples: ?IsNull(sFirstName)Function: IsArray(varname)Description: Returns a Boolean value indicating whether a variavle is an array.Examples: Dim sname As String
Dim studentName(10) As String?IsArray(sname)?IsArray(studentName)
Function: IsDate(expression)Description: Returns a Boolean value indicating whether an expression is a date.Examples: ?IsDate(BirthDate)
?IsDate(Date)Function: IsNumeric(expression)Description: Returns a Boolean value indicating whether an expression is a number.Examples: ?IsNumeric(sname)
?IsNumeric(Total)Function: IIf(expr, truepart, falsepart)Description: Returns one of two parts, depending on the evaluation of an expression.Examples: ?IIF(percentage>85,”A Grade”,”Below A Grade”)
Date and Time Functions
Function: Date()Description: To display current system dateExamples: ?DateFunction: Time()Description: To display current system time.Examples: ?TimeFunction: Now()Description: To display current system date and time.Examples: ?NowFunction: Day(date),Month(date),Year(date)Description: To get the numeric value that represents a day, Month, Year in the
month.Examples: ?Day(date) , ?Day(#12/07/2010#)
?Month(Date) , ?Month(#12/07/2010#)?Year(Date) , ?Year(#12/07/2010#)
Function: DateAdd(Interval, Number, date)Description: The DateAdd function is used to add a date value to another date.
Interval Used To Getd Daym Month
Microsoft Visual Basic Shortcut Keys and Built-in Function
yyyy Year
Examples: ?DateAdd(“m”,3,date)Function: DateDiff(Interval, Date1, Date2)Description: Returns a Variant (Long) specifying the number of time intervals
between two specified dates.Examples: ?DateDiff(“y”,BirthDate,Date)Function: MonthName(month)Description: Returns a string indicating the specified month.Examples: ?MonthName(Month(Date))Function: Second(time),Minute(time),Hour(time)Description: To get the numeric value that represents a second, Minute, Hour in the
month.Examples: ?Second(time)
?Minute(time)?Hour(time)
Function: Weekday(date)Description: Returns a Variant (Integer) containing a whole number representing the
day of the week.Examples: ?Weekday(Date)Function: WeekdayName(weekday)Description: Returns a string indicating the specified day of the week.Examples: ?WeekdayName(Weekday(date))
Mathematical Functions
Function: Abs(number)Description: To return absolute value of a number.Examples: ?Abs(-10)Function: Cos(number)Description: Returns a Double specifying the cosine of an angle.Examples: ?Cos(15)Function: Log(number)Description: Returns a Double specifying the natural logarithm of a number.Examples: ?Log(15)Function: Rnd[(number)]Description: Returns a Single containing a random number.Examples: ?Rnd()
?Int(5*Rnd())Function: Round(expression [,numdecimalplaces])Description: Returns a number rounded to a specified number of decimal places.Examples: ?Round(8.5487,2)Function: Sgn(number)Description: Returns a Variant (Integer) indicating the sign of a number.Examples: ?Sgn(15)Function: Sin(number)Description: Returns a Double specifying the sine of an angle.Examples: ?Sin(15)Function: Sqr(number)Description: Returns a Double specifying the square root of a number.Examples: ?Sqr(15)
Miscellanies Functions
Function: LoadPicture(filename)Description: Loads a graphic into a form’s Picture property, a PictureBox control, or
an Image control.Examples: Picture1.Picture = LoadPicture("c:\GreenStone.bmp")Function: Shell(pathname)Description: Runs an executable program and returns a Variant (Double)
Microsoft Visual Basic Shortcut Keys and Built-in Functionrepresenting the program's task ID if successful, otherwise it returns zero.
Examples: Shell ("c:\windows\system32\mspaint.exe")Function: TypeName(varname)Description: Returns a String that provides information about a variable.Examples: Dim sName As String
Dim dSalary As Double ? TypeName(sName) ? TypeName(dSalary)
Function: VarType(varname)Description: Returns an Integer indicating the subtype of a variable.Examples: Dim sName As String
Dim dSalary As Double ? VarType(sName) ? VarType(dSalary)