Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
80 Cards in this Set
- Front
- Back
.Net framework is
|
.Net class library ADO.NET 4.0 - ActiveX Data Object ASP.NET 4.0 MISL and CLR |
|
Insert tab in a string sequence |
vbTab
is a constant in VB that equivalents tab key |
|
string replacement code |
{0}
Dim myString - StringFromant("{0}!","Hello") |
|
format string as currency |
String.Format("{0:C}" , 23.35) |
|
Format a number as decimal value (0.00 and comas) Format a phone number (123) 123-45678 |
{0:N} {0:(###) ###-####} |
|
Array in VB |
Dim numbers(0 to 4) As Integer or Dim numbers(4) As Integer |
|
Array of strings |
Dim names() As String {"AAA","BBB"} |
|
For Each |
Dim names() As String {"AAA","BBB"} For Each name As String In names Console.WriteLine(name) Next |
|
function in VB |
Function name() as String
End Function |
|
procedure example |
Sub name()
End Sub |
|
IsNothing() |
checks for Null |
|
Dim dat As Date = #1/17/2012 9:30AM# Dim city As String = "Chicago" Dim temp As Integer = -16 Dim output As String =
String.Format("At {0} in {1}, the temperature was {2} degrees.", dat, city, temp) Console.WriteLine(output)
What is the output? |
At 1/17/2012 9:30:00 AM in Chicago, the temperature was -16 degrees. |
|
For Each item In temperatureInfo output = String.Format("Temperature at {0,8:t} on {0,9:d}: {1,5:N1}°F", _ item.Key, item.Value) Console.WriteLine(output) |
' Temperature at 2:00 PM on 6/1/2010: 87.5°F ' Temperature at 10:00 AM on 12/1/2010: 36.8°F |
|
write a code to open an .aspx (in shape of a pop up window) after clicking a LinkButton on another .ASPX web page(using VB) |
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim queryString As String = "test.aspx" Dim newWin As String = "window.open('" & queryString & "');" ClientScript.RegisterStartupScript(Me.GetType(), "pop", newWin, True)
End Sub |
|
Get week number |
Format(Datepart(DateInterval.WeekOfYear, Now)) |
|
Passing by value |
Sub NoChanges(ByVal N As Integer, ByVal S As Single) ' Receives arguments by value N = N * 2 'Double both S = S * 2 ' arguments ' When the calling routine regains control ' its two local variables will not be ' changed from their original values. End Sub |
|
Passing by reference |
Sub Changes(N As Integer, S As Single) ' Receives arguments by reference N = N * 2 ' Double both S = S * 2 ' arguments
' When the calling routine regains control, ' its two local variables will now be twice ' as much as they were before calling this.
End Sub |
|
namespace |
Namespace Stefan
End Namespace |
|
The ____ exception type is used to catch all generic exceptions within a Try-Catch structure. Answer 1. NullReferenceException 2. ArgumentNullException 3. OverflowException 4. SystemException |
4 SystemException |
|
To return multiple variables from a Function procedure, arguments passed ____ must be used. Answer 1. ByVal 2. BySub 3. ByRef 4. ByArg |
3 |
|
The ____ exception type occurs when a value exceeds its assigned data type. Answer
NullReferenceException
ArgumentNullException
OverflowException
SystemException |
OverflowException |
|
The keyword ____ is used in a Function procedure to return a single value. Answer
SendVal
Return
ReturnVal
ReturnValue |
Return |
|
The ____ property allows you to change the generic graphic on the splash screen. Answer
BackGround
BackImage
BackgroundImage
BackGroundPicture |
BackgroundImage |
|
The ____ Information dialog box contains values that include the program title, description, company, product, and copyright date. Answer
Assembly
ActiveX
Activity
Argument |
Assembly |
|
A For...Next loop with a beginning value of 1, an ending value of 25, and a Step value of 3 will execute ____ times. Answer
3
8
9
25 |
9 |
|
If ____ appears as the last line of a loop, the loop is a bottom-controlled Do loop that will execute as long as a condition remains true. Answer
Loop While
Do While
Loop Until
Do Until |
Loop While |
|
The ____ follows the keyword For in a For...Next loop. Answer
keyword Next
keyword Step
keyword To
control variable |
control variable |
|
What will be the value of the variable intTotalCount when the following code is executed? For intOuterCount = 1 to 5 For intInnerCount = 1 to 4 intTotalCount +=1 Next Next Answer
4
5
9
20 |
20 |
|
The ____ property of a ListBox object identifies which item in the ListBox was selected. Answer
Item
ItemSelected
Selected
SelectedItem |
SelectedItem |
|
Which line of code will add the value “East” to a ListBox object named lstDirections? Answer 1. lstDirections.Add(“East”) 2. lstDirections.Items.Add(“East”) 3. lstDirections.AddValue(“East”) 4. lstDirections.Items.AddValue(“East”) |
2 |
|
A ____ operator allows you to perform arithmetic operations with a variable and store the results back to that variable. Answer
logical
rational
compressed
compound |
Compound |
|
To remove all objects from a ListBox object, the ____ method is used. Answer
Clear
Items.Clear
Empty
Items.Empty |
Clear |
|
The ____ property of a ComboBox returns an integer value corresponding to the position of the selected item in the list. Answer
Index
CurrentIndex
SelectedIndex
SelectedInteger |
SelectedIndex |
|
The ____ object acts as a container for Visual Basic objects in a Document Actions task pane. Answer
Pane
ActionsPane
Actions
PaneControl |
ActionsPane |
|
The ____ object allows users either to select an existing value or enter a new value. Answer
ComboBox
DropDownBox
DropDownComboBox
ListBox |
ComboBox |
|
The ____ property of a Button object contains the name of the button. Answer
ID
ButtonTitle
Name
ButtonCaption |
ID |
|
The ____ object verifies that the object on a Web form contains data. Answer
EmptyObject
ObjectNull
RequiredFieldValidator
ObjectRequired |
RequiredFieldValidato |
|
The ____ procedure converts a string value to uppercase letters. Answer
ToUpper
ToUpperCase
ConvertToUpper
UpperCaseConvertf |
ToUpper |
|
The ____ procedure of the String class is used to remove spaces from the string. Answer
TrimSpaces
TrimEnds
Trim
TrimEndSpaces |
Trim |
|
Writing to a Text File |
Dim file As System.IO.StreamWriterfile = My.Computer.FileSystem.OpenTextFileWriter("c:\test.txt", True)file.WriteLine("Here is the first string.")file.Close() |
|
Reading a file |
DIM objReader As IO.StreamReader
if IO.File.Exist("e:\inventory.txt") = True Then objReader = IO.File.OpenText("e:\inventory.txt") Else MsgBox0"The file is not available. Restart the program when the file is available",,"Error") Me.Close() End If |
|
Creating a two-dimensional array |
Dim intVal(2,3) As Integer |
|
Declare and init an array |
Dim intCalories() As Integer = { 35, 45, 75, 119} |
|
General format for BinarySerach procedure |
intValue = Array.BinarySearch(arrayname, value) |
|
General Format for Sort procedure |
Dim intAges() as Integer = {16,64,41,8,19} Array.Sort(intAges) |
|
Passing an array
An array cna be passed as an argument to a Sub procedure or a Function procedure |
... ComputerDisplayTtl(decCommissionAmounts) ...
Private Sub ComputeDisplayTtl(ByVal decValueOfCommission() As Decimal)
Dim decAmount as Decimal Dim decTotal as Decimal = 0
For Each decAmount in decValueOfCommission decTotal += decAmount Next
lblTotalCommission.Text = "The Total Commission is " _ & decTotal.ToString("C")
End Sub
|
|
For each General format |
For Each Control Variable Name in ArrayName
' CODE
Next |
|
Reinitializing an Array |
Every array in VB is considered dynamic. When you change the number of elements in an existing array, you re-dimension it.
Dim strEmployee(50) As String ' Later in code ReDim strEmployees(65)
When you ReDim statement all the data contained in the array is lost when the array is re-dimensioned. if you want to preserve the existing data, you can used the keyword Preserver.
Dim strEmployee(50) As String ' Later in the code RedDim Preserver strEmployee(65) |
|
Upper-Bound Index Constant |
An array can use a constant value representing the upper-bound inded of the array.
Const intUpperBound As Integer = 40 Dim strFirstNames(intUppeerBound) As String |
|
Init an Array with Default Values |
When you initialize an array, if you do not assign values immediately, each element is assigned a default value
All numeric data type = 0 String data type = Null Boolean data type = False |
|
Multiple catch blocks def |
Multiple Catch blocks can be defined for a single Try block where each Catch block will catch a particular class of exception |
|
Exception thrown when a variable that has value is passed to a procedure |
ArgumentNullException
Dim strTemr as String lstDisplay.Items.Add(strTerm) |
|
Exception thrown when a value is divided by zero |
DividedByZeroException
intResult = intNum / 0 |
|
Exception thrown when a variable is converted to another type that is not possible |
FormatException
strTerm = "Code" intValue = Convert.ToInt32(strTerm) |
|
Exception thrown when a procedure is called when the result is not possible |
NullReferenceException
Dim strTerm as String intValue = strTerm.Lenght |
|
Exception thrown a value exceeds its assigned data type |
OVerflowException
Dim intCost as Interger intCost = 58 ^ 400000000000
|
|
The generic SystemExceptions |
Generic
Catches all other exceptions |
|
General format for Try-Catch block |
Try ' Try block Catch (filter for possible exceptions) ' Catch block End Try |
|
By default, a class-level variable delared using the Dim statement has ______________ access |
private |
|
Function procedure call |
Private Function FunctionProcedureName() as DataType ' Line(s) of code REturn VariableName End Function |
|
Passing arguments by reference (ByRef) |
This is the second way in which to pass an argument from a calling procedure to a called sub procedure by reference |
|
Procedure call |
Private Sub ProcedureName()
' Lines of code
End Sub |
|
Event handler is executed when the user select the island location of the hour |
SelectedIndexChanged |
|
Bottom-Controlled Do Until Loop |
This Do Until loop checks the condition after the body of the loop is executed.
The loop continues until the condition becomes try
Do ' Loop Body
Loop Until condition |
|
Priming a loop |
Starting a loop with a preset value in the variable tested in the condition is called priming the loop |
|
Do Until Loops |
A Do Until loop can be both top-controlled and bottom-controlled. The top controlled loop is
Do Until condition ' Loop Body Loop |
|
Bottom-Controlled Do While Loop |
Do ' Loop Body Loop While condition
Do While loop where the condition is tested at the bottom of the loop. |
|
Top-controlled loop vs bottom-controlled loop |
Top-controlled loop - tests the condition before the loop is entered. The body of this type of loop might not be executed at all.
Bottom-controlled loop - tests the condition at the bottom of the loop, so the body of a bottom-controlled loop is executed at least once. |
|
For...Next loop |
For Control Variable = Beginning Number Value to Ending Numeric Value
' Body of the loop
Next |
|
General Format to Assign the Selected Item in a ListBox Object |
strVariableName = lstListBoxName.SelectedItem |
|
To clear the items in a ListBox object used |
lstListBoxName.Items.Clear() |
|
General format for adding an item to a ListBox obj |
Me.Controls.Add(listBox1) |
|
Site.master file |
it is a file master page that provides an overall layout for the site with headers, buttons, and footers. Master page is designed to create a consistent layout for the pages in your application |
|
Example of getting the string from an input box |
Dim strAge As String strAge = InputBox("Please enter your age", "Driver's License Agency") |
|
A procedure cannot detect at run time whether a given argument has been omitted or the calling code has explicitly supplied the default value. If you need to make this distinction, you can set an unlikely value as the default. The following procedure defines the optional parameter office, and tests for its default value, QJZ, to see if it has been omitted in the call: |
Sub notify(ByVal company As String, Optional ByVal office As String = "QJZ") If office = "QJZ" Then Debug.WriteLine("office not supplied -- using Headquarters") office = "Headquarters" End If ' Insert code to notify headquarters or specified office. End Sub |
|
Enum EggSizeEnum Jumbo ExtraLarge Large Medium SmallEnd Enum |
Enum EggSizeEnum Jumbo ExtraLarge Large Medium SmallEnd Enum Public Sub Iterate() Dim names = [Enum].GetNames(GetType(EggSizeEnum)) For Each name In names Console.Write(name & " ") Next Console.WriteLine() ' Output: Jumbo ExtraLarge Large Medium Small Dim values = [Enum].GetValues(GetType(EggSizeEnum)) For Each value In values Console.Write(value & " ") Next Console.WriteLine() ' Output: 0 1 2 3 4 End Sub |
|
List of Strings using a collection initializer |
Dim currencies = New List(Of String) From { New String("AFA-Afghanistan Afghani"), New String("ALL-Albanian Lek"), New String("DZD-Algerian Dinar"), New String("ARS-Argentine Peso"), New String("AWG-Aruba Florin") } |
|
List(Of Customer) collection by using a collection initializer |
Dim customers = New List(Of Customer) From { New Customer("City Power & Light", "http://www.cpandl.com/"), New Customer("Wide World Importers", "http://www.wideworldimporters.com/"), New Customer("Lucerne Publishing", "http://www.lucernepublishing.com/") } |
|
Equivalent code to generate the following List of advertiser Dim customers = New List(Of Customer) From { New Customer("City Power & Light", "http://www.cpandl.com/"), New Customer("Wide World Importers", "http://www.wideworldimporters.com/"), New Customer("Lucerne Publishing", "http://www.lucernepublishing.com/") } |
Dim customers = New List(Of Customer) customers.Add(New Customer("City Power & Light", "http://www.cpandl.com/"))customers.Add(New Customer("Wide World Importers", "http://www.wideworldimporters.com/"))customers.Add(New Customer("Lucerne Publishing", "http://www.lucernepublishing.com/")) |
|
friend assembly example |
Imports System.Runtime.CompilerServicesImports System<Assembly: InternalsVisibleTo("AssemblyB")> ' Friend class. Friend Class FriendClass Public Sub Test() Console.WriteLine("Sample Class") End Sub End Class ' Public class with a Friend method. Public Class ClassWithFriendMethod Friend Sub Test() Console.WriteLine("Sample Method") End Sub End Class
|