Test 3 CShet - C lass methods Public Class ValidationClass...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Class methods Public Class ValidationClass Public Function CheckInteger( ByVal InputString As String ) As Integer Try-Catch to Validate Integer Try ResultInteger = Integer .Parse(InputString) Catch ex As Exception Return -1 End Try After user inputs wrong type / integer, this focuses to that textbox Me.OrderNumberTextbox.Focus() Private Shared Variables used between methods in a class (ex. mTotalSalesDecimal) Property Syntax Private decBalance as Decimal Public Property Balance() As Decimal Get Return decBalance End Get Set(ByVal value As Decimal) decBalance = value End Set End Property ReadOnly Example Public ReadOnly Property Grade() As String Get Grade = mGrade End Get End Property WriteOnly Example Public WriteOnly Property Midterm() As Short Set(ByVal Value As Short) mMidterm = Value End Set End Property Student Grade Code Private Sub btnGrade_Click(ByVal sender As . .. 'Declarations Dim mGrades As New StudentGrade 'Input mGrades.Midterm = nudMidterm.Value mGrades.Paper = nudPaper.Value mGrades.Final = nudFinal.Value 'Processing Call mGrades.CalcGrade() 'Output lblPercent.Text = mGrades.Percent.ToString lblGrade.Text = mGrades.Grade End Sub Chapter 10 Array of Size 10: Dim strPaint(9) As String Prepopulated 1 Element Array: strPaint(0) = “Royal Blue” Reading Values from an Array: lblPaintColor.Text = strPaint(0) Prepopulating: Dim varName() as Type = {List} 2-D Array: Dim shoPoints(3, 4) as Short Array Methods: GetLowerBound, GetUpperBound, Length ReDim – resizes an array Preserve – keyword used to preserve data when resized Structures Public Structure sEmployee Dim strLast as String…… End Structure Declaring Structures: Dim Employee as sEmployee Create an array with 10 structures: Dim Employees(9) as sEmployee Populating Structures Employee(0).strFirst = “Anne” Loop For i=0 to 4 Employee(i).decGross = Employee(i).sngHours * Employee(i).decPayRate Next i Structures Potential Problems Data types must conform to needs of data, structures must be created
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/29/2010 for the course MIS 304 taught by Professor Mote during the Fall '08 term at University of Texas at Austin.

Page1 / 3

Test 3 CShet - C lass methods Public Class ValidationClass...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online