Download presentation
Presentation is loading. Please wait.
1
Prepared By: Deborah Becker
Built-In Functions Chapter 3.6 1/18/2019 Prepared By: Deborah Becker
2
Prepared By: Deborah Becker
Topics Common Built-In Functions Numeric Functions Val() and Str() String Functions Formatting Functions 1/18/2019 Prepared By: Deborah Becker
3
Common Built-In Functions
Types Formatting Numeric String Date & Time File handling 1/18/2019 Prepared By: Deborah Becker
4
Prepared By: Deborah Becker
Formatting & Printing Using the Print Zones Each line in a Picture box object or paper line is divided into zones. Each zone contains 14 positions about the size of a printed character We use the Print method of the picture box to display our output We use Commas and Semicolons to separate items on the print line Using Commas will display the data in different print zone Using Semicolons will display the data in a line with no spaces. 1/18/2019 Prepared By: Deborah Becker
5
Prepared By: Deborah Becker
Examples picDisplay.Print strName, strPhone Deborah Becker (816) picDisplay.Print strname; strPhone Deborah Becker(816) 1/18/2019 Prepared By: Deborah Becker
6
Prepared By: Deborah Becker
The Tab() function Tab(n) This function is used to position data into the various positions on the print line n Represents the position on the line where the data item will print. Example picDisplay.Print strName; Tab(20); strPhone Deborah Becker (816) 1/18/2019 Prepared By: Deborah Becker
7
Prepared By: Deborah Becker
Spc() Function The Spc(n) function is used Print and Print# statements to generate spaces. Example picDisplay.Print strName; Spc(5); strPhone Deborah Becker (816) 1/18/2019 Prepared By: Deborah Becker
8
Common Numeric Functions
Sqr(NumericVariable) Sqr(9) = 3 Sqr(319) = Int(NumericVariable) Int(3*5.9) = 17 Int(-2.7) = 3 The values inside the function can be number, numeric variables or numeric expressions Round(curPartPrice * IntQtyOrder, Digits) Round(2.356 * 5, 3) = 1/18/2019 Prepared By: Deborah Becker
9
Prepared By: Deborah Becker
Other Functions Val(Text Expression) User Input into TextBox Store results of Calculation Converts string variable to numeric value Produces an error if input is not numeric Useful is data is stored in string format Str(Numeric Expression) Converts Input in a TextBox to Numeric 1/18/2019 Prepared By: Deborah Becker
10
Prepared By: Deborah Becker
Solve These Functions sngPrice = Val(“3.16”)*5 sngPrice = int(3.16 * 5) sngPrice = Round(3.16*5) sngPrice = int(3.16) * 5 15.8 15 15.8 15 1/18/2019 Prepared By: Deborah Becker
11
Prepared By: Deborah Becker
String Functions Left(strVariable,Number of Characters) Mid(strVariable, StartPosition,#Characters) Ucase(srtVariable) Trim(“ “) Right(strVariable, Number of Characters) From the right most character Len(strVariable) Instr(strVariable, String Pattern) Returns the starting position in the string 1/18/2019 Prepared By: Deborah Becker
12
Prepared By: Deborah Becker
Solve These Examples Left(“CIS202”, 3) Right(“CIS202”,3) Mid(“Visual Basic”, 3, 2) Ucase(“visual Basic”) Lcase(“COMPUTERS”) Len(“Watcher, the Movie”) Instr(“Watcher, the Movie”, “at”) If the str2 is not a subset of str1 the values = 0 Else if str2 is a subset of str1 the value = the starting position of str2. (2) Trim(“ This class is too Early “) 1/18/2019 Prepared By: Deborah Becker
13
Prepared By: Deborah Becker
Date and Time Function FormatDateTime(dtmClassTime,vbLongDate) FormatDateTime(dtmClassTime,vbShortDate) Monday, September 18, 2000 09/18/00 1/18/2019 Prepared By: Deborah Becker
14
Prepared By: Deborah Becker
Formatting Numbers formating symbol is used to line up numbers and decimal points in output FormatNumber() FormatCurrency() FormatPercent() FormatDateTime() 1/18/2019 Prepared By: Deborah Becker
15
Prepared By: Deborah Becker
Setting TxtBox.Text txtBox.text = FormatNumber( ,0) txtBox.text = FormatCurrency(123.45) txtBox.text = FormatCurrency(123.45,0) Use a format function to correctly display the following currency 09/18/00 long date currency no cents 1/18/2019 Prepared By: Deborah Becker
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.