VisualBasic is an easy-to-learn and powerful programming tool from Microsoft. It is a visual, object-oriented and event-driven structured high-level programming language. VB can easily develop various applications suitable for Windows environment. .
This article mainly introduces the vb language code Daquan, which is explained in detail from the five commonly used vb language codes. Let's take a look at it with Xiaobian.
Vb language code Daquan1, numerical function:
Abs(num): returns the absolute value
Sgn(num): num>0 1; num=0 0; num<0 -1;
Hex(num): Return hexadecimal value directly: &Hxx up to 8 digits
Oct(num): Return octal value directly: &Oxx up to 8 bits
Sqr(num): returns the square root num>0
Int(num): round int(99.8)=99; int(-99.2)=100
Fix(num): round the fix(99.8)=99; fix(-99.2)=99
Round(num,n): rounding off decimal places
Round(3.14159,3)=3.142 The midpoint value is rounded to the nearest even round (3.25,1)=3.2
Log(num): take the base e logarithm
Num>0 exp(n): take the nth power of e usually used
Num^n sin(num): Trigonometric function, calculated in radians (angle *Pai)/180=radian con(num); tan(num); atn(num)
2, the string function:
Len(str): Calculate the length of the string Chinese characters are also counted as one!
Mid(str, start character, [read length]): intercepts the string intermediate substring
Left(str,nlen): intercepts the nlen length substring from the left
Right(str,nlen): intercepts the nlen length substring from the right
Lcase(str): string is converted to lowercase
Ucase(str): string is converted to uppercase
Trim (str): remove the spaces at both ends of the string
Ltrim (str): remove the space to the left of the string
Rtrim (str): remove the space to the right of the string
Replace(str, find string, substitute string, [start character, substitution number, comparison method]): replace string
Note: Default value: start character 1; number of substitutions is not limited; comparison method is case sensitive (0)
InStr ([start character,] str, find string [, comparison method]): check whether the substring optional parameter is required to return to the starting position at the same time
InStrRev (str, find string [, start character] [, comparison method]): reverse detection whether substring is returned to the starting position space(n): string constructing n spaces
String(n,str): Constructs a string consisting of n first characters of str. StrReverse(str): reverses the string
Split(str, split string [, number of times] [, comparison method]): use a split string as a split flag to convert a string into a character array.
3, the data type conversion function:
Cint(str): converts a positive number True -1; False 0; date distance 1899/12/31 days; time morning 0; afternoon 1;
Cstr(str): date output format yyyy/mm/dd; time output format Am/Pm hh:mm:ss Clng(str): similar to Cin()
Cbool(num): num is not zero True; otherwise False
Cdate(str): conversion date format 0: #Am 12:00:00#; date of positive number distance 1899/12/31 days; floating point date + decimal time
Cbyte(num): num<255 converted to bytes
Csng(str): convert to single precision value
Cdbl(str): convert to double precision value
Ccur(str): convert to cash format
4, time function:
Date: take the current date of the system
Time: take the current time of the system
Now: take the current time and date value of the system
Datetime type
Timer: takes the current time distance zero seconds, the timer, can calculate the time difference
DateAdd (interval unit, interval value, date): extrapolation of adjacent dates
DateDiff (interval unit, date one, date two): calculation time difference date two - date one
Datepart (interval unit, date): Calculate the interval unit value of the date
Dateserial (date): output date value (calculated by sequence)
Timeserial (time): output time value (calculated by sequence)
Datevalue(datetime): fetch the date value in the string
Timevalue(datetime): Get the time value in the string
Weekday(date): Calculate the day of the week
MonthName (date): output month name
Year(datetime): Intercept year
Month(datetime): Intercept month
Day(datetime): interception day
Hour(datetime): Intercept hour
Minute(datetime): intercept minute
Second(datetime): intercepts seconds
5, other functions:
Array(unit,...): dynamically generating arrays
Asc(str): Output the ASCII code of the first character of the string
Chr(asc): Convert ASCII to the character Enter:Chr(13)&Chr(10) Filter (array name, key string, [, contains][, comparison method]):
Save the element containing the key string in the string array as a new array (default) [include] is false and take the element not included
Oin(ArrayName): concatenates the elements in the array into strings
Ubound(ArrayName[, dimension]): Get the upper bound of the corresponding dimension of the array
Lbound(ArrayName[, dimension]): Get the lower bound of the corresponding dimension of the array is generally 0 Randmize n: start the random number seed
Rnd(n): Get a random number, n <<0 or null, take the next random value of the sequence, n “0, the same random value, n=0, produce the same number as the previous random value
Take a random positive C between A and B, formula: C = Int((B-A+1)*Rnd+A) Condition (B"A)
Subroutine and custom functions
Sub StrSubName Function StrFunName(arg[1],...) Subprogram body function body
Exit Sub jumps out of the Exit Function halfway out
End Sub StrFunName=value return value
End Function
[call] StrSubName refers to the subroutine Var=StrFunName(arg[1],...) Reference function
10.1 Inch Laptop,win10 Laptops,win11 Laptops
Jingjiang Gisen Technology Co.,Ltd , https://www.gisentech.com