有如下程序:Private Type stuX As StringY As IntegerEnd TypePrivate Sub Command1 Click( )Dim a As stuX="ABCD"Y=12345Print aEnd Sub程序运行时出现错误,错误的原因是( )。A.Type定义语句没有放在标准模块中B.变量声明语句有错C.赋值语句不对D.输出语句Print不对

题目

有如下程序:

Private Type stu

X As String

Y As Integer

End Type

Private Sub Command1 Click( )

Dim a As stu

X="ABCD"

Y=12345

Print a

End Sub

程序运行时出现错误,错误的原因是( )。

A.Type定义语句没有放在标准模块中

B.变量声明语句有错

C.赋值语句不对

D.输出语句Print不对


相似考题
更多“有如下程序:Private Type stuX As StringY As Integer End TypePrivate Sub Command1 Click( )D ”相关问题
  • 第1题:

    在窗体上画一个名称为Command1的命令按钮,然后编写如下程序:

    Private Sub Commandl_Click( )

    Static X As Integer

    Static Y As Integer

    Cls

    Y=1

    Y=Y+5

    X=5+X

    Print X, Y

    End Sub

    程序运行时,3次单击命令按钮Command1后,窗体上显示的结果为【 】。


    正确答案:15 6
    15 6 解析:在本题过程中使用了两个Static变量,其中的变量Y每次都被重新赋值,因此不管执行多少次,Y的结果只会是6;而变量X的值则一直累计,执行3次后,x为15。

  • 第2题:

    有如下程序: include using namespace std; class TestClass { private: int x,y; pu

    有如下程序: #include<iostream> using namespace std; class TestClass { private: int x,y; public: TestClass (int i,int j) { x=i; y=j; } void print() { cout<<"print1"<<end1; } void print()const { cout<<"print2"<<end1; } }; int main() { const TestClass a(1,2); a.print(); return 0; } 该程序运行后的输出结果是( )。

    A.print1

    B.print2

    C.print1 print2

    D.程序编译时出错


    正确答案:B
    解析:由主函数main入手,定义TestClass型的常对象a,然后调用对象a中的成员函数print()。因为在C++中,如果一个对象被声明为常对象,则不能调用该对象中的非const型的成员函数。所以,这里调用的是对象中的const型成员函数“void print()const”,输出为print2。

  • 第3题:

    有如下程序:include using namespace std;class sample{private: int x, y;public: s

    有如下程序: #include <iostream> using namespace std; class sample { private: int x, y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<<"displ"<<end1; } void disp() const { cout<<"disp2"<<end1; } }; int main () { const sample a(i,2); a.disp (); return 0; } 该程序运行后的输出结果是( )。

    A.disp1

    B.disp2

    C.disp1 disp2

    D.程序编译时出错


    正确答案:B
    解析:C++中,在定义常对象时必须进行初始化,而且不能被更新。如果将一个对象说明为常对象,则通过该对象只能调用它的常成员函数。题中,对象a被定义成类sample的常对象,所以通过对象a只能调用其常成员函数disp()。所以程序最后输出disp2。

  • 第4题:

    有类定义如下:

    class Type{

    public:

    Type(int i=0);

    Type operator-(int);

    friend Type operator+(Type,Type);

    private:

    int val;

    };

    若有对象定义Type c1;则下列语句序列中,错误的是

    A.Type(3)+c1;

    B.c1+Type(3);

    C.3-c1;

    D.c1-3;


    正确答案:C

  • 第5题:

    程序段如下:Private Sub Command1_ Click() a = 0 for 1=15 To 15 Step- 2 a = a +1 Next I Print a, IEnd Sub发生Command 1的单击事件后,程序的输出结果是 ______。

    A.0 13

    B.15 13

    C.0 15

    D.15 15


    正确答案:B
    解析:for循环的结束条件是循环变量在变化方向上超过终值。当发生Command1_Click事件时,给变量a赋值为0,执行for循环,给循环变量I赋值15,循环变量的终值为15,步长为-2,变化方向是从大到小。循环变量的值没有超过终值,执行循环体,给a赋值15,循环变量加上步长变为13,已经在变化方向上超过了终值,循环结束。输出的a和I的值分别为15和13。

  • 第6题:

    在PL/SQL中定义一个可以存放雇员表(EMP)的员工名称(ENAME)的PL/SQL表类型,应该()

    A.type array arr_type[emp.ename%type] index by binary_integer;

    B.type table arr_type[emp.ename%type] index by binary_integer;

    C.type arr_type is table of emp.ename%type index by binary_integer;

    D.type arr_type is pl_sql table of emp.ename%type index by binary_integer;


    参考答案:C