1、 1 算法复习二(数据的基本类型与赋值上机学案) 一、数据基本类型与赋值 Private Sub Command1_Click() Dim a As Integer 定义整型变量 Dim b As Integer 定义整型变量 Dim c As Integer 定义整型变量 Const Pi = 3.14159 定义一实数常量 a = Val(Text1.Text) val()转化为数字 b = Val(Text2.Text) c = a * b text3.text=str(c) str()转化为文本 End Sub Private Sub Command2_Click() Dim scor
2、e(1 To 3) As Integer 定义一整数型数组 Dim price(1 To 3, 1 To 4) As Double 定义一双精度实数型二维数组 For i = 1 To 3 通过循环语句给数组赋值 score(i) = i * 2 Next For i = 1 To 3 通过循环语句输出数组的值 Print “score(“ & i & ”):” & score(i)&连接字符串 Next for i=1 to 3二维数组赋值 for j=1 to 4 price(i,j)=i*j next next for i=1 to 3 依次输出二维数组元素 for j=1 to 4 p
3、rint “score(“ & i & “,” & j & ”):” & score(i,j) next next End sub 2 二、圆的面积计算 Private Sub Command1_Click() Dim r As Double Const pi = 3.1416 r = Val(Radius.Text) Radius 第一个文本框名称 Area.Text = Str(pi * r * r) Area 第二个文本框名称 End Sub 三、程序填空 有如下Visual Basic程序段: Dim i As Integer, s As Integer i = 1 s = 0 Do While i 3