basic语言的基本命令
Basic语言命令_卡西欧5800命令

Abs 函数返回数的绝对值。
And 运算符执行两个表达式的逻辑连接。
Array 函数返回含一数组的变体。
Asc 函数返回字符串首字母的 ANSI 字符代码。
赋值运算符 (=) 给变量或属性赋值。
Atn 函数返回数的反正切值。
调用语句将控制移交 Sub 或 Function 过程。
CBool 函数返回已被转换为 Boolean 子类型的变体的表达式。
CByte 函数返回已被转换为字节子类型的变体的表达式。
CCur 函数返回已被转换为货币子类型的变体的表达式。
CDate 函数返回已被转换为日期子类型的变体的表达式。
CDbl 函数返回已被转换为双精度子类型的变体的表达式。
Chr 函数返回指定 ANSI 字符码的字符。
CInt 函数返回已被转换为整数子类型的变体的表达式。
Class 对象提供对已创建的类的事件的访问。
Class 语句声明类名Clear 方法清除 Err 对象的所有属性设置。
CLng 函数返回已被转换为 Long 子类型的变体的表达式。
颜色常数颜色常数列表。
比较常数用于比较运算的常数列表。
连接运算符 (&) 强制两个表达式的字符串连接。
Const 语句声明用于字母值的常数。
Cos 函数返回角度的余弦值。
CreateObject 函数创建并返回对“自动”对象的引用。
CSng 函数返回已被转换为单精度子类型的变体的表达式。
CStr 函数返回已被转换为字符串子类型的变体的表达式。
日期和时间常数在日期和时间运算中用来定义星期几和其他常数的常数列表。
日期格式常数用于日期和时间格式的常数列表。
Date 函数返回当前系统日期。
DateAdd 函数返回加上了指定的时间间隔的日期。
DateDiff 函数返回两个日期之间的间隔。
DatePart 函数返回给定日期的指定部分。
DateSerial 函数返回指定年月日的日期子类型的变体。
DateValue 函数返回日期子类型的变体。
Day 函数返回日期,取值范围为 1 至 31。
VISUAL BASIC 常用语句74条详解

首先打开 Microsoft Excel,然后运行程序,单击命令按钮,你将看到 Excel 变成活动窗 体。
下面示例用 Shell 函数启动 Microsoft Excel,然后用 AppActivate 语句来激活 Microsoft Excel。在运行程序前,首先找到 Microsoft Excel 的路径,并关闭 Excel。
元素,以及释放动态数组的存 23
储空间。
模拟错误的发生。
23
定义用户自定义的事件。
24
提前退出控制结构、循环或过
程的语句体。
26
3
20 FileCopy 语句
复制一个文件。
27
21 ForEach...Next 语句
针对一个数组或集合中的每个
元素,重复执行一组语句。
28
22 For...Next 语句
建立一标准工程,在窗体上添加一命令按钮,将下面的程序粘贴过去。 Private Sub Command1_Click() On Error GoTo ErrorHandler '发生错误转到错误处理入口
MsgBox "程序运行" Exit Sub '程序运行完毕,没有错误退出程序 ErrorHandler: '错误处理入口 Beep '发出声响。 MsgBox "出错" End Sub
13 Do...Loop 语句
14 End 语句 15 Enum 语句 16 Erase 语句 17 Error 语句 18 Event 语句 19 Exit 语句
basic语言基本命令

BASIC语言的基本命令包括以下几种:1. CLS:清除屏幕。
2. PRINT:打印文本或变量。
3. INPUT:从用户输入读取数据并赋值给变量。
4. LET:将值赋给变量。
5. IF...THEN:执行条件语句。
6. FOR...LOOP:执行循环结构。
7. GOSUB:调用子程序。
8. RETURN:从子程序中返回。
9. END:结束程序。
10. WHILE...WEND:执行循环结构(与FOR...LOOP类似)。
11. RESTORE:从文件恢复程序。
12. SAVE:保存程序到文件。
13. OPEN:打开文件进行读写操作。
14. READ/WRITE:读写文件中的数据。
15. CLOSE:关闭已打开的文件。
16. ON...GOTO:跳转到标签位置。
17. ON...CASE:执行多分支条件语句。
18. SELECT CASE...CASE:执行多分支条件语句。
19. ELSE:在IF语句中作为“否则”部分。
20. AND:逻辑与运算符。
21. OR:逻辑或运算符。
22. NOT:逻辑非运算符。
23. XOR:逻辑异或运算符。
24. SHIFT:位移动运算符(左移和右移)。
25. CREATE:创建新的内存变量或数组。
26. DIMENSION:声明数组或用户自定义类型。
27. DO...LOOP:执行循环结构(与FOR...LOOP类似)。
28. EXIT:退出循环或子程序。
29. ELSEIF...THEN:在IF语句中作为“否则如果”部分。
30. WHILE...WEND:执行循环结构(与FOR...LOOP类似)。
希望以上信息能帮到你。
Visual Basic 的基本语法

• (在VB句相似,在 需要进行多个选择时,使用它的代码 可读性更好 • Select Case 语句的语法:
Select Case testexpression [Case expression 1 [statements-1]] [Case expression 2 [statements-2]] … [Case Else [statements-n]] End Select
– For...Next – While…Wend
31
For…Next 循环语句
• 使用 For…Next 语句将一组语句重复执行 指定的次数 • For…Next 语句的语法:
For Variable = Vtart To End [Step n] Statements [Exit For] Next [Variable]
• • • • • • <:小于 >:大于 =:等于 <>:不等于 <=:小于或等于 >=:大于或等于
21
逻辑运算符
• AND:逻辑与
• OR: 逻辑或 • NOT:逻辑非
22
运算符优先级
算术 比较 逻辑
指数运算 (^)
负数 (–)
相等 (=)
不等 (<>)
Not
And
乘法和除法 (*、 /)
整数除法 (\)
第三章
Visual Basic 的基本语法
Version 3.0
回顾
• Windows 应用程序的事件驱动设计 • Visual Basic事件编码机制
• Visual Basic中窗体和控件事件
• 编写事件处理程序代码
• 使用MsgBox函数
2
BASIC程序的语句和编码规则

Byte Boolean Integer Long Single
双精度型 Double
பைடு நூலகம்
类型 符 无 无
% & !
前缀
byt bln int lng sng
#
dbl
所占字节数
1 2 2 4 4
8
货币型 Currency
@
cur
8
日期型 Date(time)
无
dtm
8
字符型 String
$
str 与字符串长度有关
3)浮点数
浮点数也称为实型数或实数,由符号、指数和尾数构成,分单精度 浮点数(Single)和双精度浮点数(Double),其指数部分分别用 “E”(或“e”)和“D”(或“d”)表达。
4)货币型(Currency) 货币型属于定点实数或整数,用8位字节存储小数点前有15位,小 数点后有4位,其他旳数字被舍去,其表达形式为在数字后加上 “@”。
对象型 Objiect
无
obj 4
变体型 Variant
无
vnt 根据分配拟定
范围
0~255 True与False -32768~32767 -2147483648~2147483647 负数:-3.402823E38~-1.401298E-45 正数:1.401298E-45~3.402823E38
5.结束语句
结束语句用来正常地结束一种程序旳执行。结束语句旳格 式为:
End 如下面旳程序:
Private Sub Timer1_Timer() End
End Sub
6.With 语句
With 语句旳语法为: With 对象
[语句块] End With
basic 用法

basic 用法
"basic" 是一种编程语言,也被称为BASIC(Beginner's All-purpose Symbolic Instruction Code)。
它是一种易于学习和使用的高级编程语言,适用于初学者。
以下是 BASIC 的一些基本用法:
1. 输出文本:使用 PRINT 语句可以在屏幕上打印文本。
例如:PRINT "Hello, World!"
2. 变量:可以使用 DIM 语句声明变量,并使用 LET 语句给变量赋值。
例如:DIM x AS INTEGER : LET x = 10
3. 数学运算:BASIC 支持常见的数学运算,如加法、减法、乘法和除法。
例如:LET x = 5 + 3
4. 条件语句:使用 IF...THEN...ELSE 语句可以根据条件执行不同的代码块。
例如:
IF x > 10 THEN
PRINT "x 大于 10"
ELSE
PRINT "x 小于等于 10"
END IF
5. 循环结构:BASIC 提供了多种循环结构,如 FOR...NEXT 循环和 DO...LOOP 循环,可以重复执行一段代码。
例如:
FOR i = 1 TO 10
PRINT i
NEXT i
6. 用户输入:使用 INPUT 语句可以获取用户的输入,并将其保存到变量中。
例如:INPUT "请输入您的姓名:", name$ 这只是 BASIC 的一些基本用法,还有更多高级特性和功能可供探索。
freebasic 编程

freebasic 编程FreeBASIC是一种免费的、开源的编程语言,它继承了BASIC语言的简单易学和直观的特点,并添加了现代编程语言的一些功能。
它可以用于开发各种类型的应用程序,包括命令行工具、桌面应用程序和游戏等。
FreeBASIC的语法简单明了,非常容易上手。
下面是一些FreeBASIC编程的基本语法:1. 变量和数据类型:- 声明变量:使用`Dim`关键字声明变量,如`Dim x As Integer`- 数据类型:包括整型(`Integer`)、单精度浮点型(`Single`)、双精度浮点型(`Double`)等。
- 数组:可以使用`Dim`关键字声明数组,如`Dim arr(10) As Integer`2. 控制流语句:- `If-Then`语句:用于执行条件判断,如`If x > 0 Then Print "Positive"`- `For-Next`语句:用于循环执行一段代码,如`For i = 1 to 10 Step 2 : Print i : Next`- `Do-Loop`语句:用于执行循环,如`Do While x < 10 : x = x + 1 : Loop`- `Select-Case`语句:用于根据不同的条件执行不同的代码块,如`Select Case x : Case 1 To 5 : Print "Small" : Case 6 To 10 :Print "Big" : End Select`3. 函数和过程:- 函数:使用`Function`关键字定义函数,如`Function Add(a As Integer, b As Integer) As Integer : Return a + b : End Function` - 过程:使用`Sub`关键字定义过程,如`Sub Display(x As Integer) : Print x : End Sub`4. 文件和输入输出:- 文件读写:使用`Open`和`Close`函数实现文件的打开和关闭,使用`Input`和`Print`函数实现文件的读写操作。
Visual Basic 命令分类表

Visual Basic 命令分类表(N/A)本分类表仅包括部分Visual Basic对初学者有用的命令,限于篇幅,如果您想了解命令的详细用法,请参看VB帮助或其它有关VB书籍。
有一点需要记住的是:不要把VB命令同VB控件的属性混淆!一、顺序文件随机文件二进制其它 I/O二、字符串 DOS 显示声明三、QUICKBASIC专用命令内存/数组 DEFCUR DEFCUR四、循环和条件五、图形过程文件类型事件处理六、数字逻辑数据类型端口错误处理本分类表仅包括部分Visual Basic对初学者有用的命令,限于篇幅,如果您想了解命令的详细用法,请参看VB帮助或其它有关VB书籍。
有一点需要记住的是:不要把VB命令同VB控件的属性混淆!------------------- ------------------- -----------------------------顺序文件随机文件二进制其它 I/O------------------- ------------------- -----------------------------OPEN WRITE# OPEN GET OPEN GET DATA RUNCLOSE PRINT# CLOSE PUT CLOSE PUT READ CHAINRESET PRINT# USING RESET FIELD RESET LOCK RESTORE INKEY$EOF INPUT# EOF LSET EOF UNLOCK ENVIRON LPRINTLOC LINE INPUT$# LOC RSET LOC FREEFILE ENVIRON$ TABLOF FREEFILE LOF MK... LOF INPUT$ SYSTEMLOCK SEEK CV... SEEK LINE INPUT$ SLEEPUNLOCK SEEK# LOCK SEEK# VIEW PRINT ENDFILEATTR FREEFILE UNLOCK FILEATTR DATE$ STOPFILEATTR TIME$ LPOSTRON STICKRND # range: int((up-lo+1)*RND +lo) TROFF STRIG IOCTL REMIOCTL$------------------- ------------ ------------------- -----------------字符串 DOS 显示声明------------------- ------------ ------------------- -----------------UCASE$ CHR$ SHELL LOCATE COLOR Main ProceduresLCASE$ ASC FILES PRINT SOUND --------- ----------LEFT$ VAL NAME CLS CLEAR DECLARELTRIM$ SPC KILL BEEP PLAY COMMONRIGHT$ SPACE$ MKDIR VIEW PRINT POS OPTION BASERTRIM$ STR$ CHDIR WIDTH CSRLIN CONSTMID$ INSTR RMDIR DEF FNLEN STRING$ FILEATTR STATIC STATICLSET SWAP DIR$ SHARED SHAREDRSET FRE DIM DIMENVIRON REDIM REDIMENVIRON$ DEFINT DEFINT----------------------------- ------------------------ DEFSTR DEFSTR QUICKBASIC专用命令内存/数组 DEFCUR DEFCUR----------------------------- ------------------------ DEFINT DEFINT LOCAL ALIAS $INCLUDE PEEK BLOAD VARPTR DEFLNG DEFLNGSADD BYVAL Int86 POKE BSAVE VARPTR$ DEFSNG DEFSNGSETMEM CDECL Int86x CLEAR UBOUND VARSEG DEFDBL DEFDBLSIGNAL COMMAND$ INTERRUPT ERASE LBOUND FRE TYPE... TYPE...EVENT UEVENT INTERRUPTX DEF SEGVARPTR SSEGVARSEG----------------------------------------------------------------------循环和条件---------------------------------------------------------------------- FOR i TO j STEP k WHILE cond IF__THEN__ELSE SELECT CASEEXIT FOR - CASE __ , __NEXT WEND - IF__THEN CASE IS condELSEIF__THEN__ CASE __ TO __DO WHILE|UNTIL cond ELSE__ CASE ELSEEXIT DO ENDIF END SELECTLOOP WHILE|UNTIL cond------------------ ------------------- ------------------- ----------- 图形过程文件类型事件处理------------------ ------------------- ------------------- ----------- PSET LINE SUB ... INPUT ON KEY() GOSUBPRESET CIRCLE FUNCTION ... OUTPUT " COM() "POINT DRAW CALL APPEND " PEN "BSAVE PAINT GOTO RANDOM " PLAY() "BLOAD PALETTE GOSUB BINARY " STRIG() "PCOPY VIEW RESUME " TIMER() "PMAP WINDOW RETURN " __ GOSUB _,_,_SCREEN COLOR CALL ABSOLUTE " __ GOTO _,_,_SOUND "=Numeric ExpCOM ON|OFF|STOP数字逻辑数据类型端口错误处理------------------- --------- ------------------- ----------- -------- HEX$ RND MOD IMP AS SINGLE FIX INP ERDEV ERROCT$ SGN ABS AND " DOUBLE CINT OUT ERDEV$ ERLSWAP SIN SQR OR " LONG INT WAIT ON ERROR ERROREXP COS LOG XOR " INTEGER CSNGTAN LET ATN NOT " STRING CDBL ON ERROR GOTORANDOMIZE EQV CLNG ON LOCAL ERROR GOTOON ERROR RESUME NEXTON LOCAL ERROR RESUME NEXTRESUMEEVENT ONEVENT OFFRETURN。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
basic语言的基本命令Basic command (2009-09-2420:34:02)Reprint TAB: it classification: compiler authoringThe assign statement (LET) (format) LET variable = the expression (function) assigns a data to a variable. The essay is made out of the basic statement. The value of the expression is the data to be assigned to the variable. The expression can be either a number or an arithmetic. 【 application 】 LET A = 5 (2) suspension of statements (PAUSE) PAUSE time format 】【【 features 】 to suspend execution, or delay for A period of time. 【 description 】 (1) when let robot motion, is to control the robot by the length of time the distance of the forward and backward, and the left and right rotation Angle. The specific value of time is the length of time, which can be accurate to milliseconds. The phrase "PAUSE 1000" means that the delay time is set to 1 second. 3. The END of the statement (END) END format 】【【 features 】 terminates 4. Loop statement (FOR/NEXT) FOR loop variable = initial value TO the final STEP STEP length (...... The circulatory body... )NEXT variable FOR loop statements (circular entrance) NEXT cycle final value statements (cycle export) 【 features 】 do statement used to perform a fixed number of repetitions. The initial value, final value, and step length of the loop variable can be constant or variable. When the STEP length is 1, STEPcan be omitted. It is necessary to use the name of the loop variable. The nested layer of the loop is no more than 8 layers.The SOUND (SOUND) [function] gives the SOUND of a given tone for the duration of the specified duration. The module has been integrated into port 10 of the general robot motherboard. Voice frequency value, is the actual frequency value, can send out the frequency of the people's ears to hear, in the practical application, can be appropriately changing the frequency of the sound to correct intonation, sound frequency zero for the rest. Unconditional transfer statement (GOTO) (format) the GOTO mark (function) unconditionally moves to the specified row label to execute the program. An article is a symbol for an address. The bidding number is terminated by the colon and appears before the execution statement, not before the non-executable. 7.注释语句(REM)【格式】 REM 字符串【功能】释语句的主要作用是为了增强程序的可读性,在程序执行中并不被执行,即REM”后的语句只是起到说明作用。
【说明】⑴ 为了提高程序的可读性,可以在程序的适当位置加上一些注释,注释可以放在程序的任何位置。
⑵ REM后面可以是任何内容。
⑶ REM可以用单引号代替“’”。
【应用】 REM 机器人走图形 8.条件转移语句(IF/THEN)【格式】IF 条件表达式 THEN 标号【功能】根据条件表达式是否成立,决定程序的流向。
【说明】⑴ 在条件语句中,条件表达式的值如果为真,那么转到给定的标号去执行程序,否则执行条件语句的下一个语句。
⑵ 在使用条件语句前,要对算术表达式、关系表达式、逻辑表达式以及有关知识有一个初步的了解和认识。
① 算术表达式:算术运算符:+(加)、-(减)、*(乘)、/(除)、^(乘方)、(、)圆括号算术表达式:用算术运算符和括号,将常量、变量和函数连接起来的式子。
② 关系表达式关系运算符:=(等于)、<>(不等于)、=>或>=(大于等于)、=<或<=(小于等于)、>、(大于)< (小于)。
关系表达式的运算结果是一个逻辑值,逻辑值只有两个,真(1)和假(0)。
The condition is true, its value is true, the condition is not valid, its value is false. Logical expression logic operator: AND (with), OR (OR), NOT (NOT). Logical expression: a formula that connects multiple relational expressions using logical operators. The result of the logical expression is a logical value. The results are as follows: A AND B are true, B is true, AND the logical expression is true. A OR B, A, and B, as long as one is true, the logical expression is true. In the combination of logical operation, relational operation and mathematical operation, the order of operation must be indicated in parentheses. The range of mathematical operations is 0 ~ 65535, no more than the integer division, which is the quotient. Reading statement/set statement (READ/DATA) (format) READ variable 1, variable 2,... Variable N DATA constant 1, constant 2,... Constant N, which USES DATA in the DATA statement to assign values to the corresponding variable in the READ statement. 【 description 】 the variable 1, variable 1,... The variable N is a comma-separated set of variables, with no sign at the end. Constant 1, constant 2,... Constant N is a comma-separated set of data, with no sign at the end. The READ/DATA statement must be paired, and the READ statement can only be a variable, not a constant or an expression. (4) the DATA in the DATA statement can only be constant, not a variable or expression, and the DATA statement non-executive statements, the location of the DATA statement without restrictions, but must be before the END statement. The READ statement is READ in order, and if the reading exceeds the actual data, the data READ is unknowable. RESTORE the data area statement (RESTORE) [format] RESTORE the RESTORE statement, resetting the reading pointer to the start location. The RESTORE statement is usedin conjunction with the reading statement/set statement (READ/DATA).When the program executes the RESTORE statement and then executes the READ statement, the variable in the READ statement begins to READ the DATA from the first DATA in the first DATA statement in the program. Multiple BRANCH statements (BRANCH)The BRANCH variable, (the label 0, the label 1, the label n), turns to different Numbers depending on the value of the variable. If the value of the variable is zero, then go to the label 0; Go to the label 1, and so on. If the value of the variable is greater than n, then execute the next statement. While this statement is used to those who need according to the value of a variable for different occasions, to deal with so that you can use multiple branching statements go to a few different label. 12. The conditions for statement 1 (the DO WHILE LOOP) [form] DO WHILE conditional expression block 1 block 2 LOOP EXIT DO statement execution function 】【 DO WHILE statement when they check whether a conditional expression. The conditional expression is set up, and the LOOP body language is executed, and the DO WHILE statement is returned automatically when the LOOP statement is executed, otherwise the statement under the LOOP statement is executed. Each cycle begins with an examination of whether the conditional expression is established, and if it is not established at the beginning, the loop terminates immediately. In the loop statement, you must change the statement of the variable in the conditional expression, otherwise you will have a dead loop, and you can EXIT the loop with the EXIT DO statement. The "EXIT DO" is optional, and the "do-loop" LOOP contains multiple EXITDO statements. The "do-loop" LOOP statement can be embedded in the block IF statement as a whole, and the block IF statement can be embedded in the do-loop statement as a whole. The "do-loop" LOOP statement can be nested, or it may be nested with the for-next LOOP. 13. Conditions for statement 2 (DO - LOOP WHILE) block format 】【 1 block 2 LOOP EXIT DO statement WHILE conditional expression 【 features 】 to execute a LOOP body unconditionally when performing a DO statement. When performing the LOOP statement, check if the conditional expression is formed.The conditional expression automatically returns the DO statement, otherwise the statement under the LOOP statement is executed. Verify that the expression is established at the end of each loop, rather than at the beginning of the loop. The main difference between it and the DO WHILE loop is that the first cycle must be executed. A cycle must be performed. 14. Statements define a variable (SYMBOL) SYMBOL variables = type format 】【【 features 】 byte variables, it is a variable, words are required to use the SYMBOL to use statements define. In the general QBASIC language, bit0 ~ bit32, byte variable b0 ~ b4, word variable w0 ~ w1, can be used directly. In addition to the above variables, the other byte variables can be used directly; Other variables, word variables, must be defined using the SYMBOL statement. (3) = WORD SYMBOL variables defined as double BYTE variables SYMBOL = BYTE is defined as a single-byte variables can be omitted (not write) = BIT is defined as a variable SYMBOL variables (4) in a program, most of the available variables is 128 bytes, such as using the double BYTE variable, make two Spaces. Conditional branch statements 15. Block structures (IF/THEN/ELSE) IF conditionalexpression format 】【 THEN block 1 ELSE block 2 END IF 【 features 】 IF conditional expression, execute the statement block 1, THEN turn to the next statement in the END IF statements. When the conditional expression is not valid, the ELSE and block 2 are executed, then the next statement of the END IF statement is executed. The phrase "IF to END IF" is a conditional conditional transfer statement. Diction in the block structure conditional branch statements, but lack the ELSE and block 2, when the conditional expression, does not perform any statements, go to the END of the IF statement to the next statement execution. The word "END IF" is two words, and there must be Spaces in the middle.。