ASC: Returns an Integer representing the character code of the first letter in a string.
Example: ASC("A")=65
ABS: Returns the absolute value of the argument, which is of the same type as the parameter
Example: Abs(-50.3)=50.3
SGN: Returns a Variant (Integer) that indicates the plus or minus sign of the argument.
Example: MySign = Sgn(5) ' Returns 1.
MySign = Sgn(-6) ' Returns -1.
MySign = Sgn(0) ' Returns 0.
Sqr:Returns a Double, specifying the square root of the argument.
Example: MySqr = Sqr(4) ' returns 2.
space:Returns a Variant (String) with a specified number of spaces.
Example: Dim MyString
' Returns a string with 10 spaces.
MyString = Space(10)
' Inserts 10 spaces between two strings.
MyString = "Hello" & Space(10) & "World"
spc: Used with the Print # statement or the Print method to position the output. With the spc(n) function you can skip n spaces.
Example: print "abc";spc(n); "def"
But note: print "abc "+spc(n)+"def" is wrong while print "abc "+spc(n)+"def" is correct, spc can't be used for expressions.
instr:Returns Variant (Long) specifying the position of the first occurrence of a string in another string
Format: instr([first character position,] string1. string2, [, n])
n is used to specify the way in which strings are compared.
When n=0, binary comparison is performed, case sensitive. (Default)
when n=1, the comparison ignores case
when n=2, the comparison is based on the information contained in the database, which is rarely tested.
Example: instr(4, "space", "e",1) 'return 5, meaning the fourth character in space to start looking for the character e, and ignore the case, the return result indicates that the position of e in the space of the fifth character, it should be noted that the instr should be counted spaces, such as space before 2 spaces, then the return is 7.
left: returns Variant (String), which contains the string with the specified number of characters counted from the left.
Example: left("abcde",3) 'Returns abc
right:Returns Variant (String) containing the specified number of characters from the right side of the string.
Example: right("abcde",3) 'Returns cde
mid:Returns Variant (String) containing the specified number of characters from the string
Example: mid("abcdehjgd",3,4) 'Returns cdeh, which means 4 characters taken from the 3rd character in the string. starting with 4 characters.
Note: these three functions are to count spaces;
And here mid is a function, mid can also be a string statement, the format is mid$(string, position [,L])=substring, meaning that the characters from the "string" position with a substring instead of the characters, if there is an L auto variable, it is not a string. If there is an L independent variable, then the replacement is the L characters to the left of the substring.
ucase: converts lowercase letters to uppercase letters
Example: ucase("fkjf") 'returns FKJF
Lcase: converts uppercase letters to lowercase letters
Example: lcase("jJKg") 'returns jjkg
lbound: returns a Long type data whose value is the smallest subscript available for the specified array dimension.
Example: Dim Lower
Dim MyArray(1 To 10, 5 To 15, 10 To 20) 'Declares an array variable.
Dim AnyArray(10)
Lower = Lbound(MyArray, 1) 'Returns 1.
Lower = Lbound(MyArray, 3) 'Returns 10.
Lower = Lbound(AnyArray) 'Returns 0 or 1. Depends on
'Option Base setting.
ubound:Returns a Long whose value is the largest subscript available for the specified array dimension.
Example: Dim Upper
Dim MyArray(1 To 10, 5 To 15, 10 To 20) 'Declares an array variable.
Dim AnyArray(10)
Upper = UBound(MyArray, 1) 'Returns 10.
Upper = UBound(MyArray, 3) 'Returns 20.
Upper = UBound(AnyArray) 'Returns 10.' < /p>
ltirm,rtirm,tirm: are functions that remove whitespace characters from the left, right, and both left and right sides of a string
Example: a$=ltirm(" jkl ") 'Returns "jkl"
b$=rtirm(" jkl ") 'Returns " jkl"
c$= tirm(" jkl ") 'The return is "jkl"
val:Converts a number in a string to numeric data.
Example: enter 1 in text1, 2 in text2, but print text1.text + text2.text the result is 12, this is because the result of the input in the text is a character type, but if you change to print val (text1.text) + val (text2.text), the The result is 3
int (number), fix (number): return to the integer part of the parameter, do not round, but note that the Cint function to rounding. Int and Fix the difference is that if the number of negative numbers, Int returns less than or equal to the number of the first negative integer, while Fix will return greater than or equal to the number of the first negative integer. The difference between Int and Fix is that if number is negative, Int returns the first negative integer less than or equal to number, while Fix returns the first negative integer greater than or equal to number. For example, Int converts -8.4 to -9, while Fix converts -8.4 to -8.
Example: int(-8.4)=-9
fix(-8.4)=-8
rnd: Returns a Single containing a random number
Before calling Rnd, initialize the random number with the parameterless Randomize statement to initialize a random number generator with a seed based on a system timer.
To generate random integers within a certain range, the following formula is used:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Here, upperbound is the upper limit of the range of the random number and lowerbound is the and lowerbound is the lower limit of the random number range.
(2) Calculation:
To remember the order, in fact, with our usual calculation of the difference is not much difference, it should be noted that the function is the first to calculate
floating-point division (/) prior to the integer division (\),
mod operation between multiplication and division and addition and subtraction.
Integer division is rounded before integer division, and the result of division is truncated without rounding.
Smaller number \ larger number = 0
Smaller number mod larger number = smaller number
Comparison of character strings: it is compared according to its ascii code value, the first comparison of the first character, ascii code value of the character where the string is large, if the first character is the same, then compare the second character, and so on.
Here are some of the corresponding ascii code values:
The ascii code values of 0~9 on the large keyboard are 48~57
The ascii code values of 0~9 on the small keyboard are 96~105
The ascii code values of a~z are 97~122
The ascii code values of A~Z are 65~95
Esc's ascii code value is 27
Space's ascii code value is 32
(3) Frequently Tested Control Properties
caption,name,width,height,enable needless to say.
left,top: when the control is a form, its value is relative to the screen; when the control is a control within the form, its value is relative to the form.
(a)labels:alignment,autosize,borderstyle,backstyle
(b)textboxes:passwordchar,scrollbars,text
Their events:change,gotfocus, lostfocus,
its method: setfocus
(c)Graphic Controls
stretch: this property applies to the image box (image), but the book of the higher education version of the explanation and msdn's explanation is different, but I think it should be to msdn shall prevail, after all, this is the ms's well!
The book is: when its value is false, will automatically zoom in or out of the image box graphics to fit the size of the image box.
msdn: True means the graphic is to be resized to fit the control.
False (default) means that the control is to be resized to fit the graphic.
The main difference between a picture box (picturerue) and an image box (image): a picture box can act as a "container" control, that is to say, a picture box can contain other controls, while an image box can not; a picture box can accept text, while an image box can not.
Load the graphics file statement: [object...] picture=loadpicture("file path"), when the file path is empty, you can delete the graphics in the picture box.
(d)Button controls
cancel:When this property is true, pressing esc has the same effect as clicking the command button.
default: When this attribute is true, pressing enter has the same effect as clicking this command button.
(e) Selection controls
value: radio buttons can be set to true and false, but for multiple choice buttons it is 0 - means the checkbox is not selected, 1 - means the button is selected, 2 -- means the checkbox is disabled.
(f)Selection Controls
Properties:
list: used to list the contents of the table items, can also be used to change the value of an existing array
listcount: listcount: the number of items in the list box, the list of items in the list box, the arrangement of the table items start from 0, the last item of the serial number is listcount-1
listindex:The set value of this attribute is the position of the selected table item, the position of the table item is specified by the index value, the index value of the first item is 0.
selected:You can check whether the specified table item is selected listbox.selected (index value)
You can select the specified table item or the canceled table item listbox. selected (index value) =true|false
text: text for the last selected table item
Events:
additem: used to insert a line of text into the list box
listbox.additem item string[,index value]
removeitem: used to remove the specified item from the listbox
listbox.removeitem index value
Combobox style attributes: 0 -- dropdown combobox, can be typed in, recognizes dropdown events
1 --Simple combo box, allows input, recognizes dblclick event
2 --Dropdown list box, does not allow input, recognizes dropdown event
(g)Scrollbar
Attributes:
max,min:value value changes between the two
largechange:incremental increase or decrease in value value when clicking on a non-scroll box part of the scrollbar
smallchange:incremental increase or decrease in value attribute when clicking on the arrows at the ends of the scrollbar
value: indicates the current position on the scroll box bar
Events:
scroll: the scroll event is triggered when dragging the scroll box within the scroll bar, but not when clicking on the scroll arrows or the scroll bar
change: triggered after changing the position of the scroll box, and gets the last value of the scroll bar
(h)timer
enable
intervar attribute: used to set the interval between timer events, the value of 1000 is 1 second
timer event: every time an interval of time specified by the attribute interval, a timer event is generated
(i)frame. Nothing special to test, but still need to know, I'll test the questions on the machine
(j)setfocus method: set the focus, you can not directly in the form-load event with setfocus, you must use the show method to display the form first. Format: control.setfocus
tab order: tabstop and tabindex
(4)Now the control structure of the control, the focus here is on the for loop structure
(a) single line structure: if ......then ......[else......]end if or
Block structure: if......then
... ...
[elseif......then
......]
else...... p>
end if
There's not much to say about this one, it's "if......then......"
And then there's the IIf function, who is the if ......then......else......end if shorthand
Format: s=IIf (condition, true part, false part) Meaning is to return the true part if the condition is true and the false part if it is false.
(b) Multi-branch control structure
Example: k=text1.text
select case k
case k...... (1) 'Condition of k'
Execute command (1)
case k ......(2)
Execute command (2)
......
end select
The point to be made here is that it executes the first command that meets the condition, and for the ones that follow, it also meets the condition. Command is not executed, but also right is the k condition of the way to write, this read the book on it.
(c) when the loop: when the condition is true to execute the statement block
format: while condition
[statement block]
wend
(d) do loop control structure: there are two formats
(I) Do
[statement block]
loop[while |until loop condition]. |until loop condition]
meaning respectively that after executing the statement block when the loop condition is true the loop continues until the condition is false, and after executing the statement block until the loop condition is true the loop ends
(II)Do [while|until loop condition]
[statement block]
loop<
The meaning is that when the loop condition is true, the statement block is executed until the condition is false, and until the loop condition is true, the loop is terminated.
This should pay attention to the number of times he executes the loop and the value of the parameters defined in the statement block after the execution of the statement block, to test the rate of the last there is no more than the execution of the loop more than once.
Example 1:
i=1
do
i=i+2
loop until i>17
Here, the loop is executed 9 times, and when i=17 there is also one more time when i=19 is executed, and that is when i is greater than 17 to end the loop
Example 2:
i=1
do
i=1
This is the last of the loop.
do
i=1+2
loop whilei<17
Here, the loop is executed 8 times, when i=15, the loop is executed so that i=17, at this time, i is not less than 17, so no longer execute the loop
(e) for the loop control structure
Format: for Loop variable = initial value to final value [step]
[loop body]
next loop variable
means when the loop variable is within the [initial value, final value], the loop is executed
loop count = int(final value - initial value)/step+1
when calculating, remember that the loop variable should be added to the step count every time the loop is executed
When the for loop is used in the control structure, it is necessary to add step lengths for each loop execution
(e)for loop control structure.
When for loops are used in multiple loops and in combination with arrays they are more complicated, so let's take some examples
Example 1: for i=1 to 2
for j=1 to i
for k=j to 4
x=x+1
'print x 'write it as x1
next k<
'print x ' noted as x2
next j
'print x ' noted as x3
next i
'print x ' noted as x4
What I'm trying to say here is that the position of print x relates to the output value
When removing the first 'print x 'noted as x1 the first of the line', the result of the execution is 1234567891011 (in fact, he arranges it vertically)
When removing 'print x 'noted as the first of the line x2', the result of the execution is 4 8 11 (which is also vertical)
When removing 'print x 'noted as the first of the line x3', the result of the execution is 4 11 (which is also vertical)
When taking away 'print x 'noted as the first of the line x4', the execution results in 11
Why does it turn out like this? Let's analyze:
(I): when i=1, j=1, k=1 to 4, so x=1, 2, 3, 4, here four loops are executed
(II):
when i=2, j=1, k=
1 to 4, so x=5, 6, 7, 8 (because the previous loop has made x=4, so on top of that continue to add 1 more), here also four loops are executed
When i=2, j=2, k=2 to 4, so x=9, 10, 11 (because k=j to 4=2 to 4), here three loops are executed
Well, now fetch back to look at the statement
It can be seen that the value of x1 is the one that is obtained in each loop, so the conclusion is that The value obtained in the innermost for statement is the value of each loop
The value of x2 is the last of the values of the loops at j=1, j=1 and 2 respectively
The value of x3 is the last of the values of the loops at i=1, i=2 respectively
The value of x4 is the value of the value at the end of the loop.11
Draw this on your own on your sketch paper! and you'll have an easier time understanding it!
Example 2: Private Sub Command1_Click()
For i=1 To 4
x=4
For j =1 To 3
x=3
For k=1 To 2
x=x+6
Next k p>
Next j
Next i
Print x
End Sub
Explanation: What really works is that
x=3
For k=1 To 2
x=x+6
Next k
since print x is outside the loop, so it is the value of the last loop, when i=4, x=4, but when j=3, x is reattached to 3, so x=4 is invalid, and the last two loops (k=1to2) are executed, x=3+6, and x=9+6 so the final value is 15
Example 3: This one is a combination of a loop and an array
Dim a(3, 3) As Integer
Private Sub Command1_Click() 'Call the array (not sure if this is correct)
aaa
For m = 0 To 2
For n = 0 To 2
Print a(n, m);
Next n
Print 'Make the values you get when m = 0, 1, 2 line feed
Next m
End Sub
Private Sub aaa() 'Define the array
For m = 1 To 3
For n = 1 To 3
a(m - 1, n - 1) = m + n + 1
Next n
Next m
End Sub
The point to be made here is that when assigning values to an array using a for loop, the first level corresponds to the rows of the array, and the second level corresponds to the columns of the array, and then you can find the value of each of the array aaa() based on a(m - 1, n - 1) = m + n + 1, which can be written out as follows The following is much simpler and clearer to write.
n=1 2 3
m= 1 3 4 5
2 4 5 6
3 5 6 7
Example 4: This is a question from page 183 of the textbook
Private Sub Command1_Click()
x=5
for i=1 to 20 step 2
x=x+i\5
next i
print x
End Sub
Here to say is that we do not forget next i here, each time the loop is finished i have to add step, i = 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, and 1\ 5=3\5=0,5\5=7\5=9\5=1......
(f)About passing value and address
It's all about remembering: byval: when the formal parameter changes, the real parameter doesn't change
byref: when the formal parameter changes, the real parameter changes along with it
I didn't learn this one very well either, so let's gain some experience as we learn!
II. On the part of the machine
On the machine is to do some simulation questions, as if the examination of the question there are a lot of questions are previously examined, in many simulation questions have seen, and how to rely on the luck of the test, draw the easy questions over the problem should not be a problem, difficult to the tragedy, so do a little more simulation questions. There are also on-line exams when you have to read and write files have a little skill!