文档库 最新最全的文档下载
当前位置:文档库 › Rough Terrain Visual Odometry

Rough Terrain Visual Odometry

Rough Terrain Visual Odometry
Rough Terrain Visual Odometry

Rough Terrain Visual Odometry

Motilal Agrawal

Arti?cial Intelligence Center SRI International Menlo Park,CA,USA Email:agrawal@https://www.wendangku.net/doc/1413127012.html,

Kurt Konolige

Arti?cial Intelligence Center SRI International

Menlo Park,CA,USA Email:konolige@https://www.wendangku.net/doc/1413127012.html,

Abstract—We present an integrated system to localize a mobile robot in rough outdoor terrain using visual odometry. Our previous work[1]presented a visual odometry solution that estimates frame-to-frame motion from stereo cameras and integrated this incremental motion with a low cost GPS. We extend that work through the use of bundle adjustment over multiple frames.Bundle adjustment helps to reduce the error signi?cantly,thereby making our system more robust and accurate while still operating in real-time.Our new system can keep the robot well localized over several hundreds of meters to within1%error.We present experimental results for our system over a300meters run in a challenging environment and compare it with ground truth Real Time Kinematic(RTK)GPS.

I.I NTRODUCTION

Visual Odometry(VO)[1],[2]is a relatively new tech-nology for localizing mobile robots.VO works by?nding interest points in the images and matching them between successive images.Robust methods are then used to estimate the camera motion from these matched interest points.Since cameras are inexpensive and provide high information band-width,they can serve as cheap and precise localization sensor. In addition,processing power has increased signi?cantly to a point that such visual motion estimation can now be performed in real time on standard processors.

VO for outdoor terrains is in some ways more challenging than indoor environments.Firstly,outdoor environments are unstructured,and simpler features such as corners,planes and lines that are abundant in indoor environment rarely exist in natural environments.Secondly,outdoor terrains can be rough and undulating.Thus planar motion assumptions that are so common in indoor envoronments are not applicable. Succesful navigation over such rough terrains requires a euclidean motion model that utilizes the full six degrees of freedom.Another consequence of the rough terrain is that bumps in the ground can cause motion abruptness thereby making visual registration harder.Lighting changes and shadows also make it harder to match images. Although motion estimation from video has been a widely researched topic in computer vision,real-time systems utiliz-ing vision for localization of robots have been very few.One of the?rst of these systems was presented by Nister[3]for a monocular camera.Davison[4]also presented a real time monocular system using the extended kalman?lter.However, their approach is best suited for indoor environments because of algorithmic complexity and growing uncertainty in feature locations.When compared to monocular video,motion esti-mation from stereo images is relatively easy and tends to be more stable and well behaved.Another major advantage of using stereo cameras is that one need not worry about the scale ambiguity present in monocular camera case.VO for stereo cameras was presented by Nister et al;[2]and Agrawal et al;[5],[1].

In our earlier work[5],[1],we presented a real time VO system and integrated it with an inexpensive GPS system to provide localization with≈5%error over100meters or so.However,the motion estimation algorithm was sub optimal since it estimated the incremental motion between two consecutive frames.This work enhances our previous VO system through the use of bundle adjustment over multiple frames.In this work,features are tracked for as many frames as possible,and a sliding window of frames and features(the ‘bundle’)are adjusted in a non-linear optimization,to give the best motion estimate.

Bundle adjustment[6]is a process that iteratively adjusts the camera pose and the3D location of the interest points in order to minimize the reprojection error of the interest points in all the camera frames.Global bundle adjustment is a non linear,compute intensive process and is usually used in its sparse form[7],[8]and invoked whenever a new frame is added to the system.We approximate each iteration of the bundle adjustment by alternating between estimation of the camera motion and3D scene reconstruction. We initialize our approximate bundle adjustment with the camera pose obtained from our incremental VO algorithm[1]. Since we have stereo images,we initialize the3D location of the interest points through stereo triangulation.Bundle adjustment helps to reduce the error signi?cantly,thereby making our system more robust and accurate while still operating in real-time.

Our system is most similar to the recent work of Mouragnon et al.[9]with a few major differences.Firstly, they use a monocular camera while ours is a stereo algorithm. Secondly,our bundle adjustment process for stereo alternates between pose computations and3D leading to faster conver-

gence and run time.Therefore we can use all the frames of the sequence without discarding the non key frames.We integrate our VO system with a cheap IMU/GPS system to maintain global pose consistency.Finally we present results of our robot navigating over rough terrain whereas[9] presents results over smooth roads.

Figure1shows our robot in action on a typical terrain.

A pair of stereo cameras are located on the sensor mast of the robot looking outward.The cameras are pointed forward at a slight angle.The baseline is12cm and the height above ground is about0.5m.This arrangement presents a challenging situation:short baseline and a small offset from the ground plane makes it dif?cult to track points over longer distances.A pair of wheel encoders and an Xsens IMU are used to complement the visual pose system.A Garmin GPS sensor is located on top of the sensor

mast.

Fig.1.Our robot in typical terrain.Robot is part of a DARPA project, Learning Applied to Ground Robots(LAGR).Two stereo systems are on the upper crossbar.

The rest of the paper is organized as follows.First we present our incremental visual odometry algorithm in Section II.Our bundle adjustment process is explained in Section III.Fusion with GPS and IMU sensors is described in Section IV.Results on long robot runs are presented and compared to ground truth RTK GPS in Section V and?nally Section VI concludes this presentation and discusses ongoing and future work.

II.I NCREMENTAL VO

Our visual odometry system[5],[1]uses feature tracks to estimate the relative incremental motion between two frames that are close in time.Interest points which are Harris corners are detected in the left image of each stereo pair and tracked across consecutive frames.These interest points are then triangulated at each frame based on stereo correspondences. Three of these points are used to estimate the motion using absolute orientation.This motion is then scored using the pixel reprojection errors in both the cameras.We use the disparity space homography[10]to evaluate the inliers for the motion.In the end,the hypothesis with the best score (maximum number of inliers)is used as the starting point for a nonlinear minimization problem that minimizes the pixel reprojection errors in both the cameras simultaneously, resulting in a relative motion estimate between the two frames.The IMU and the wheel encoders are also used to ?ll in the relative poses when visual odometry fails.This happens due to sudden lighting changes,fast turns of the robot or lack of good features in the scene(e.g.blank wall). Thus it complements the visual pose system.

We have found that the approach outlined above is very ef?cient and works remarkably well,even for stereo rigs with a small baseline.The fact that we are triangulating the feature points for each frame,builds a?rewall for error propagation.However,this also means that there will be a drift when the rig is stationary.In order to avoid this drift, we update the reference frame(the frame with reference to which the motion of the next frame is computed)only when the robot has moved some minimum distance(taken to be 5cm in our implementation).The fundamental reason that our approach gives reliable motion estimates,even in small-baseline situations,is our use of image-based quantities,and treating both the left and right images symmetrically.

III.B UNDLE ADJUSTED VO

Bundle adjustment[6]iteratively adjusts the camera pose and the3D location of the interest points in order to minimize the reprojection error of the interest points in all the camera frames.For bundle adjustment to be effective,interest points need to be tracked over multiple frames.Our incremental VO was computed frame-to-frame,that is,feature points were extracted for frame1and frame2,the motion between the frames was computed,and then the features were discarded. In the bundle adjusted VO,features are tracked for as many frames as possible,and a sliding window of frames and features are adjusted in a non-linear optimization,to give the best motion estimate.This optimization step reduces the error resulting in very accurate poses.

Our two-frame matching algorithm[1]can be used to link the interest points over the multiple frames.In addition,since we get the motion from our incremental VO algorithm and we have stereo,we can predict the location of the interest point in the current frame.This drastically cuts down the search space for feature matching and helps?nd matches for additional interest points which did not match previously due to ambiguity caused by large regions in which to search for the match.Furthermore,we use only those interest points which are inliers to the computed motion from the two frame algorithm and also can be tracked over at least m frames.This ensures that only good tracks are used for bundle adjustment. Bundle adjustment is a non linear,compute intensive process and is usually used in its sparse incremental form[7], [8],[9]and invoked whenever a new frame is added to the system.Each bundle adjustment is performed over a sliding

window of N frames,n of whose motion is already known (1≤n

?Initialize the pose of all the other frames from previous bundle adjustment

?Iterate till convergence

1)Structure Computation:For each inlier feature,

compute the3D location from the image tracks

and the current poses of the frames

2)Motion Computation:For each of the N?n

frames,compute its pose from the3D locations

of the feature points and its corresponding image

locations

3)Compute the reprojection errors for convergence

test

Our bundle adjustment interleaves structure and motion computation in the main loop.Motion of the most recent frame is initialized from the results of incremental VO. Motion of all the other frames is initialized from the results of previous bundle adjustment.Given the motion of each stereo frame,we can reconstruct each feature point and get its3D location.This structure computation is then followed by re?ning the motion using the structure to bootstrap.These two steps are described brie?y next.More details can be found in[11].

A.Structure Computation

Denote by x i j the coordinates of the j?th point as seen by the i?th camera.Let P i denote the projection matrix of the i?th camera and let X j be the3D location of the point. Therefore we have x i j=P i X j.Given x i j and P i,X j can be recovered easily through Direct Linear Transform(DLT). B.Motion Computation

Recovering P i from x i j and X j is nonlinear process and can be accomplished using Levenberg-Marquardt minimiza-tion.The quantity to be minimized in this case is the geometric distance between the measured and the projected

point

min

P i

ij

d(P i X j,x i j)(1)

where d(x,y)is the geometric image distance between x and y

The above interleaving of structure and motion computa-tions minimizes the same cost functions as bundle adjustment and it should result in the same solution as the full blown bundle adjustment,provided it converges.Since we have a very good initial estimate of the motion from the incremental VO,it only takes a few iterations for the interleaving to converge.Interleaving has the added advantage that it is computationally very ef?cient since at each step we only are dealing with either motion or structure computations.

IV.S ENSOR FUSION

In order to maintain a long term accurate global pose,we performed two types of?ltering on the bundle adjusted VO output.These?lters provide the necessary corrections to keep errors from growing without bounds.

1)Gravity Normal:The IMU records tilt and roll based

on gravity normal,calculated from the three accelerom-eters.This measurement is corrupted by robot motion, and is moderately noisy.

2)GPS Yaw:The IMU yaw data is very bad,and cannot

be used for?ltering(for example,over the150m run, it can be off by60degrees).Instead,we used the yaw estimate available from the LAGR GPS.These yaw estimates are comparable to a good-quality IMU.

Over a very long run,the GPS yaw does not have an unbounded error,as would an IMU,since it is globally corrected;

Our?lters for the gravity normal and yaw are very simple linear?lters that essentially nudge the robot’s pose towards global consistency through a very small gain factor.GPS yaw ?ltering is done when the GPS receiver has at least a3D position?x and the vehicle is travelling0.5m/s or faster,to limit the effect of velocity noise from GPS on the heading estimate.In addition,?ltering is performed only if the robot has travelled a certain distance from the last?ltering.This limits the effect of short term noise in the fused pose and also makes sure that the robot’s pose does not change when the vehicle is stationary.

Though the?lter is very simple,it is effective and improves the accuracy of the computed motion over long term.A better way would be to perhaps incorporate the yaw and grav estimates directly into the bundle adjustment,using their covariances.Unlike our previous work[1],we have turned off any position?ltering based on GPS i.e;we completely ignore position estimates from the GPS.The bundle adjusted VO does a very good job of estimating the distance travelled.As long as the yaw is accurate,the robot will stay well localized.

V.R ESULTS

We surveyed a course using an accurate RTK GPS receiver. The‘Canopy Course’was under tree cover,but the RTK GPS and the LAGR robot GPS functioned well.Sixteen waypoints were surveyed,all of which were within10cm error according to the RTK readout.The total length of the course was about150meters.Subsequently,our robot was joysticked over the course,stopping at the surveyed points. The robot was run forward over the course,and then turned around and sent backwards to the original starting position. The course itself was?at,with many small bushes,cacti,

(a)Bundle adjusted

VO

(b)Bundle adjusted VO with gravity normal and yaw

?ltering

(c)RMS

error (d)Loop closure error

Fig.2.

XY localization error for the canopy

sequence

(a)Z wayoint RMS

error (b)Z loop closure

error

(c)Z error along the

route (d)Z error magni?ed

Fig.3.

Z error for the canopy sequence

downed tree branches,and other small obstacles.Notable for VO was the sun angle,which was low and somewhat direct into the cameras on several portions of the course.Figure 4shows a good scene from the LAGR robot in the shadow of the trees,and a poor image where the sun washes out a large percentage of the scene.(The lines in the images are horizon lines taken from VO and from ground plane analysis).The uneven image quality makes it a good test of the ability of VO under challenging realistic conditions.The joystick control was moderate,with no sharp turns or quick accelerations and average speed of the robot about 1m/s.Our VO algorithm was able to match interest points along the whole route,even though the average data rate was only about 5Hz.Although there were some big jumps in the images (one of over 0.5meters),the feature tracker was able to track enough features to successfully match the frames.Bundle adjustment was performed over ?ve stereo frames by matching all the features that could be tracked over those frames.Results for varying the number of frames are presented in Section V-C.

Since we do not know the exact initial heading of the robot in UTM coordinates,we used an alignment strategy that assumes there is an initial alignment error,and corrects it by rotating the VO path rigidly to align the endpoint

as

(a)A good scene as viewed from the left

camera (b)Scene washed out by the sun

Fig.4.

Sample images from the LAGR robot for the canopy course

best as possible.This strategy minimizes VO errors on the outward path,and may underestimate them.However,for the return path,the errors will be caused only by VO,and can be taken as a more accurate estimate of the error.Since the robot was moved in a loop,the difference between the initial and ?nal pose can also be used as a measure of error,and this measure is not corrupted by the initial heading problem.We analyzed the following errors:

1)XY distance error between the VO poses and the RTK poses.

2)Z distance error between the VO poses and the RTK

poses.Z error is less accurate on the RTK poses,and is also globally correctable by gravity normal for VO.

3)Initial vs.?nal pose for VO,in XY and Z.

A.XY Error

Figure2compares the XY locations of the waypoints with ground truth RTK GPS.Figure2(a)shows the best result obtained using our bundle-adjusted VO with gravity normal and GPS yaw?ltering.As shown,the errors between way-points is very small,amounting to less than1%of distance traveled.Without?ltering,the results are worse(Figure2(b)), amounting to about3%of distance traveled.At some points in the middle of the return trip,the VO angle starts to drift, and at the end of the backward trip there is about a10m gap. Note that this effect is almost entirely caused by the error in the yaw angle,which can be corrected by a good IMU. Figure2(c)shows the RMS error between VO(with different?lters)and the RTK waypoints,on the return path. As noted above,the forward VO path of the robot has been aligned with the RTK path.Without yaw?ltering,the bundle adjustment does much better than the non-bundle adjusted VO.It is marginally better with yaw?ltering.Both versions of VO beat the LAGR GPS over the150meters of the return path.

We can also examine the loop closure error(Figure2(d)), looking at the difference between start and end positions.As noted,this measure is not in?uenced by the initial angle.The loop errors,without?ltering,are quite large for non-bundled VO.The bundled VO does a respectable job of keeping the error low without?ltering,amounting to about3%of distance traveled(300m).With yaw?ltering,the errors are comparable to the waypoint errors,and less than1%of distance traveled. Again,both?ltered VO algorithms beat LAGR GPS.

B.Z Error

Figure3(a)shows the RMS error between VO(with different?lters)and the RTK waypoints,on the return path. For the Z direction,the forward-path alignment also aligns the IMU gravity normal to the camera frame.Normally,the IMU orientation with respect to the camera frame is indirect: camera to vehicle,and then vehicle to IMU.The latter is affected by things like tire pressure.For our gravity-normal ?ltering,we do a direct transformation from the IMU gravity normal to camera coordinates,based on alignment from the outward path.

Without gravity-normal?ltering,the errors are modest, less than XY errors.Bundle adjustment gives two times improvement,with and without?ltering.Both versions of VO beat the notoriously unreliable LAGR GPS over the150 meters of the return path.We also examine the loop closure error in Figure3(b).The loop errors,without?ltering,are modest for non-bundled VO.The bundled VO does a great job of keeping the error low without?ltering,amounting to <0.3%of distance traveled(300m).With gravity normal ?ltering,the errors are much less than the waypoint errors, and almost vanish for bundled VO.

Given the low error for loop closure,it is interesting to ask if the waypoint errors are caused by error in the RTK readings.Figures3(c)and3(d)plots RTK vs VO readings along the course.The?rst plot uses equal axis scales,and shows a gradual declination of about a1.5%grade along the route.We used the outward trip to align the IMU and the camera frames;then,the backward trip shows this alignment works very well,to adjust the VO readings.Most of the Z error comes in two readings in the middle of the course;we expanded the vertical scale in the next?gure.The course was relatively uniform the robot did not traverse any major ditches or hills.So the RTK readings in the middle of the course are probably anomalous.The RTK Z error is nominally40cm, and may have been worse under the tree canopy.So in this case,we can take the bundle-adjusted VO as the ground truth, and measure RTK Z errors.

C.Effect of number of frames

It is obvious that as we increase the number of frames, N,over which we perform bundle adjustment,the visual odometry results will become more accurate.Figure5plots the loop closure error for different number of frames.In the absence of any bundle adjustment(the?rst bar),the loop closure error is maximum and about23m.Performing bundle adjustment even over two frames brings the error down to 21m.This error keeps on decreasing with the number of frames until it reaches a minimum of11m for5frames. Further increasing the number of frames does not change the error much.This is due to the fact that most features can only be tracked for about?ve

frames.

Fig.5.Effect of the number of frames for bundle adjustment on the loop closure error

VI.C ONCLUSION

We have presented a complete system for localization of a robot in unstructured rough terrain,using stereo vision as

the primary sensor.The system presented here enhances our previous system through the use of Bundle adjustment over multiple frames.This helps to keep the drift error down. Bundle-adjusted VO has the potential to be an accurate substitute for RTK GPS,over distances on the order of a kilometer.With good IMU readings for yaw,and noisy gravity normal readings,it is possible to get<1%error over300m.

Our localization system has been tested in varied outdoor terrain,including under tree cover where GPS does not work very well and sandy terrain which causes lot of wheel slippage and wheel based odometer to fail.Our system is very robust-we can typically give it a goal position several hundred meters away,and expect it to get there within a meter or two.We are currently in the process of porting our system on a larger robot that can travel upto5m/s.Finally,we would also like to augment our VO system with visual landmarks to further reduce the drift error and recognize places seen before,thereby allowing us to do loop closures.

A CKNOWLEDGEMENT

The work reported in this paper was supported in part by a contract with DARPA under the Learning Applied to Ground Robots program.

R EFERENCES

[1]M.Agrawal and K.Konolige,“Real-time localization in outdoor

environments using stereo vision and inexpensive gps,”in Proc.

International Conference on Pattern Recognition,August2006. [2] D.Nister,O.Naroditsky,and J.Bergen,“Visual odometry,”in Proc.

IEEE Conference on Computer Vision and Pattern Recognition,June 2004.

[3] D.Nister,“An ef?cient solution to the?ve-point relative pose problem,”

IEEE Transactions on Pattern Analysis and Machine Intelligence (PAMI),vol.26,no.6,pp.756–770,June2004.

[4] A.Davison,“Real-time simultaneaous localisation and mapping with a

single camera,”in Proc.International Conference on Computer Vision (ICCV),2003,pp.1403–1410.

[5]M.Agrawal,K.Konolige,and R.Bolles,“Localization and mapping

for autonomous navigation in outdoor terrains:A stereo vision ap-proach,”in Proc.IEEE Workshop in Applied Computer Vision(WACV), February2007,p.To Appear.

[6] B.Triggs,P.F.McLauchlan,R.I.Hartley,and A.W.Fitzibbon,

“Bundle adjustment-a modern synthesis,”in Vision Algorithms: Theory and Practice,ser.LNCS.Springer Verlag,2000,pp.298–375.

[7]K.Konolige and M.Agrawal,“Frame-frame matching for realtime

consistent visual mapping,”in Proc.International Conference on Robotics and Automation(ICRA),2007,p.To Appear.

[8] C.Engels,H.Stewnius,and D.Nister,“Bundle adjustment rules,”

Photogrammetric Computer Vision,September2006.

[9] E.Mouragnon,M.Lhuillier,M.Dhome,F.Dekeyser,and P.Sayd,

“Real time localization and3d reconstruction,”in https://www.wendangku.net/doc/1413127012.html,puter Vision and Pattern Recognition(CVPR),vol.1,June2006,pp.363–370.

[10]M.Agrawal,K.Konolige,and L.Iocchi,“Real-time detection of

independent motion using stereo,”in IEEE workshop on Motion (WACV/MOTION),January2005.

[11]R.Hartley and A.Zisserman,Multiple View Geometry in Computer

Vision.Cambridge University Press,2000.

VB程序设计课后习题答案(科学出版社)

同步练习1 二、选择题 01——05 CADAB 06——10 ACDAB 11——15 CBDBB 同步练习2 二、选择题 01——05 ABDCA 06——10 CACBC 11——15 DADAD 16——20 BDBBB 三、填空题 1.可视 2.LEFT、TOP、WIDTH、HEIGHT 3.按字母顺序 4.查看代码 5.工具、编辑器 6.FORM窗体、FONT 7.MULTILINE 8.在运行时设计是无效的 9.工程、工程属性、通用、FORM1.SHOW 10.TABINDEX、0 同步练习3 二、选择题 01——05 BCADB 06——10 ADBBC 11——15 DBCBA 16——20 BAABB 三、填空题 1.整型、长整型、单精度型、双精度型 2.SIN(30*3.14/180)+SQR(X+EXP(3))/ABS(X-Y)-LOG(3*X) 3.164、今天是:3-19 4.FALSE 5.-4、3、-3、3、-4、4 6.CDEF 7.(X MOD 10)*10+X\10 8.(35\20)*20=20 ( 35 \ 20 )* 20 = 20 9.X MOD 3=0 OR X MOD 5=0 10.27.6、8.2、8、1、100、397、TRUE、FALSE 同步练习4 一、选择题 01——05 DBCAD 06——10 CBBAB

11——15 D25BAC 16——20 CBACB 21——25 DAABC 二、填空题 1.正确性、有穷性、可行性、有0个或多个输入、有1个或多个输出2.1 2 3 3.X>=7 4.X

vb课后习题答案

VB 课后练习题参考答案 第一章 一、 1、C 2、C 3、B 4、B 5、D 6、B 7、B 8、D 二、 1、学习版、专业版、企业版 2、alt+Q 或 alt+F4 3、.vbp 、 .frm 4、固定、浮动 5、"abcd"、"VB Programing" 6、属性窗口、运行 7、对象框、事件框 8、窗体模块、标准模块、类模块 第二章 一、 1、B 2、B 3、B 4、B 5、D 6、D 二、 1、((x+y)+z)*80-5*(C+D) 2、cos(x)*sin(sin(x)+1 3、2*a*(7+b) 4、8*EXP(3)*LOG(2) 5、good morning 、 good morning 6、2001/8/25 8 2001 7 第三章 一、 1、C 2、B 3、D 4、A 5、D 、 3 6、C 7、B 8、C 9、C 10、D 11、B 12、C 13、B 14、B 15、A 16、B 17、D 18、C 19、C 二、 1、AutoSize 2、text1.setfocus 3、0 、 0 4、 picture1.picture=loadpic ture("yy.gif") 5、stretch 6、interval 7、enable 8、下拉式组合框、简单组 合框、下拉式列表框、style 9、下拉式列表框 10、条目1 、条目3 11、欢迎您到中国来、 welcome to china!! 第四章 一、 1、B 2、C 3、C 4、B 5、C 6、B 7、C 8、B 9、D 10、A 11、B 12、A 13、B 14、D 15、A 16、B 17、A 18、C 19、B 二、 1、2542=57 2、beijing 3、002.45、2.449、 24.49e-01、-2.449 4、9 10 11 5、9 6、1 2 3 7、 iif(x<=0,y=0,iif(x<=10, y=5+2*x,iif(x<=15,y=x- 5,y=0))) 8、x=7 或 x>6 或 x>5 9、x>=0 、x

VB第一章课后习题答案讲课教案

习题 一、单项选择题 1. 在设计阶段,当双击窗体上的某个控件时,所打开的窗体是_____。 A. 工程资源管路器窗口 B. 工具箱窗体 C. 代码窗体 D. 属性窗体 2. VB中对象的含义是_____。 A. 封装了数据和方法的实体 B. 封装的程序 C. 具有某些特性的具体事物的抽象 D. 创建对象实例的模板 3. 窗体Form1的Name属性是MyForm,它的单击事件过程名是_____。 A. MyForm_Click B. Form_Click C. Form1_Click D. Frm1_Click 4. 如果要改变窗体的标题,需要设置窗体对象的_____属性。 A. BackColor B. Name C. Caption D. Font 5. 若要取消窗体的最大化功能,可将其_____属性设置为False来实现。 A. Enabled B.ControlBox C. MinButton D. MaxButton 6. 若要以代码方式设置窗体中显示文本的字体大小,可通过设置窗体对象_____属性来实现。 A. Font B.FontName C.FontSize D. FontBold 7. 确定一个控件在窗体上位置的属性是_____。 A. Width或Height B. Width和Height C. Top或Left D. Top和Left 8. 以下属性中,不属于标签的属性是_____。 A. Enabled B. Default C. Font D. Caption 9. 若要设置标签控件中文本的对齐方式,可通过_____属性实现。 A.Align B. AutoSize C. Alignment D. BackStyle 10. 若要使标签控件的大小自动与所显示文本的大小相适宜,可将其_____属性设置为True来实现。 A.Align B. AutoSize C. Alignment D. Visible 11. 若要设置或返回文本框中的文本,可通过设置其_____属性来实现。 A.Caption B. Name C. Text D. (名称) 12. 若要设置文本框最大可接受的字符数,可通过设置其_____属性来实现。 A.MultiLine B. Max C. Length D. MaxLength

vb课后练习答案习题解答 (5)

第5章数组与记录 5.1 填空题 1.若要定义一个包含10个字符串元素,且下界为1的一维数组s,则数组说明语句为()。 答案:Dim s(1 To 10) As String 2.若要定义一个元素为整型数据的二维数组a,且第一维的下标从0到5,第二维下标从-3到6,则数组说明语句为()。 答案:Dim a(0 To 5,-3 To 6) As Integer 3.如果数组元素的下标值为实数,则VB系统会按()进行处理。 答案:四舍五入原则 4.数组元素个数可以改变的数组称为();数组元素可以存放不同类型数据的数组称为()。 答案:可调数组、可变类型数组 5.数组刷新语句用于()。若被刷新的数组是数值数组,则把所有元素置();若被刷新的数组为字符串数组,则把所有元素置()。 答案:清除指定数组内容、0、空字符串 10.控件数组是由一组类型和()相同的控件组成,共享()。 答案:名字、同一个事件过程 11.控件数组中的每一个控件都有唯一的下标,下标值由()属性指定。 答案:Index 12.建立控件数组有两种方法:()和()。 答案:在设计阶段通过相同Name属性值来建立、在程序代码中使用Load方法 5.2 选择题 1.下列一维数组说明语句错误的是()。 a) Dim b(100) AS Double b) Dim b(-5 To 0) AS Byte c) Dim b(-10 To –20) AS Integer d) Dim b(5 To 5) AS String 答案:c 2.若有数组说明语句为:Dim a(-3 To 8),则数组a包含元素的个数是()。 a) 5 b) 8 c) 11 d) 12 答案:d 3.设有数组说明语句:Dim c(1 To 10),则下面表示数组c的元素选项中()是错误的。 a) c(i-1) b) c(5+0.5) c) c(0) d) c(10) 答案:c 4.下列数组说明语句中正确的是()。 a) Dim a(-1 To 5,8)AS String b) Dim a(n,n)AS Integer c) Dim a(0 To 8,5 To –1)AS Single d) Dim a(10,-10)AS Double

VB语言练习题及答案1

VB语言练习题及答案 1、算法的计算量的大小称为算法的________。 (A)现实性(B)难度(C)复杂性(D)效率 2、设栈S和队列Q的初始状态为空。元素a、b、c、d、e、f依次通过栈S,并且一个元素出栈后即进入队列Q,若出队的顺序为b、d、c、f、e、a,则栈S的容量至少应该为________。 (A)3(B)4(C)5(D)6 3、在深度为5的满二叉树中,叶子结点的个数为________。 (A)32(B)31(C)16(D)15 4、链表适用于________查找。 (A)顺序(B)二分法(C)顺序,也能二分法(D)随机 5、希尔排序法属于________类型的排序法。 (A)交换类排序法(B)插入类排序法(C)选择类排序法(D)建堆排序法 6、序言性注释的主要内容不包括________。 (A)模块的接口(B)模块的功能(C)程序设计者(D)数据的状态 7.在数据流图中,○(椭圆)代表________。 (A)源点(B)终点(C)加工(D)模块 8、软件测试的过程是________。 Ⅰ.集成测试Ⅱ.验收测试Ⅲ.系统测试Ⅳ.单元测试 (A)Ⅰ、Ⅱ、Ⅲ、Ⅳ(B)Ⅳ、Ⅲ、Ⅱ、Ⅰ(C)Ⅳ、Ⅰ、Ⅱ、Ⅲ、(D)Ⅱ、Ⅰ、Ⅳ、Ⅲ 9、数据的逻辑独立性是指________。 (A)存储结构与物理结构的逻辑独立性(B)数据与存储结构的逻辑独立性(C)数据与程序的逻辑独立性(D)数据元素之间的逻辑独立性

10、一个供应商可供应多种零件,而一种零件可由多个供应商供应,则实体供应商与零件之间的联系是________。 (A)一对一(B)一对多(C)多对一(D)多对多 11、下列打开"代码窗口"的操作中不正确的是________。 (A)按F4键(B)单击"工程资源管理器"窗口中"查看代码"按钮(C)双击已建立好的控件(D)执行"视图"菜单中"代码窗口"命令12、为了同时改变一个活动控件的高度和宽度,正确的操作是 ________。 (A)拖拉控件4个角上的某个小方块(B)只能拖拉位于控件右下角的小方块(C)只能拖拉位于控件左下角的小方块(D)不能同时改变控件的高度和宽度 13、Load事件是在窗体被装入工作区时 触发的事件。 (A)用户(B)程序员(C)手工(D)自动 14、.以下Case语句中错误的是________。 (A)Case 0 To8(B)Case Is > 5(C)Case Is > 0 And Is < 6(D)Case 1, 3, Is > 5 15、以下关于函数过程的叙述中,正确的是________。 (A)函数过程形参的类型与函数返回值的类型没有关系 (B)在函数过程中,过程的返回值可以有多个 (C)当数组作为函数过程的参数时,既能以传值方式传递,也能以传地址方式传递 (D)如果不指明函数过称参数的类型,则该参数没有数据类型 16、为了同时改变一个活动控件的高度和宽度,正确的操作是 ________。 (A)拖拉控件4个角上的某个小方块(B)只能拖拉位于控件右下角的小方块(C)只能拖拉位于控件左下角的小方块(D)不能同时改变控件的高度和宽度 17、设a = 3,b = 10,c = 6,以下表达式的值是________。a < b And (Not b>c) Or c

VB第1-4章习题答案

VB习题答案(1-4) 习题1 一、选择题 1. 以下叙述中,错误的是_________。 (A)一个Visual Basic 应用程序可以含有多个标准模块文件 (B)一个visual Basic 工程可以含有多个窗体文件 (C)标准模块文件可以属于某个指定的窗体文件 (D)标准模块文件的扩展名是.bas 标准模块文件(.bas)不属于任何一个窗体文件。参考答案为C。 2. 以下叙述中错误的是_________。 (A)一个工程可以包括多种类型的文件 (B)Visual Basic应用程序既能以编译方式执行,也能以解释方式执行 (C)程序运行后,在内存中只能驻留一个窗体 (D)对于事件驱动型应用程序,每次运行时的执行顺序可以不一样 内存中可以驻留多个窗体,当前窗体只能有一个。参考答案为C。 3. Visual Basic的窗体设计器主要是用来___________。 (A)建立用户界面(B)添加图形、图像、数据等控件 (C)编写程序源代码(D)设计窗体的布局 参考答案为A。 4. Visual Basic是一种结构化高级程序设计语言,它采用的是_________驱动方式。 (A)键盘(B)鼠标(C)事件(D)函数 参考答案为C。 5. Visual Basic程序设计语言属于_________。 (A)面向过程的语言(B)机器语言 (C)面向对象的语言(D)汇编语言 参考答案为C。 6. Visual Basic一共有设计、运行和中断三种模式,要使用调试工具应该_________。 (A)进入设计模式(B)进入运行模式 (C)进入中断模式(D)不用进入任何模式 VB中三种模式分别为:设计模式下可以进行界面设计和代码的编写;运行模式下执行代码,接受用户的操作;中断模式下可以修改代码,但不能改变界面,这个模式下通常进行代码调试,当运行出错时,默认转到该模式下进行调试。参考答案为C。

vb课后习题答案

习题3—4 (P126) Private Sub Command1_Click() Image1.Width = Image1.Width * 1.2 Image1.Height = Image1.Height * 1.2 End Sub Private Sub Command2_Click() Image1.Width = Image1.Width / 1.2 Image1.Height = Image1.Height / 1.2 End Sub Private Sub Command3_Click() Image1.Width = Form1.Width Image1.Height = Form1.Height End Sub Private Sub Form_Load() Image1.Left = 0 Image1.Top = 0 Image1.Picture = LoadPicture(App.Path & "\back.jpg") End Sub 习题3—5 (P126) Dim mleft As Long Private Sub Command1_Click() Timer1.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False End Sub Private Sub Timer1_Timer() mleft = Label1.Left + 100 If mleft + Label1.Width > Picture1.Width Then mleft = 0 End If Label1.Left = mleft End Sub

VB书面习题答案(1-3章)

习题一P19 1. 3. 4. 5. 6. 7 参考答案: 1、简述Visual Basic的特点。 答:⑴基于对象的可视化设计工具 ⑵事件驱动的编程机制 ⑶提供易学易用的应用程序集成开发环境 ⑷结构化的程序设计语言 ⑸强大的网络、数据库、多媒体功能 ⑹完备的联机帮助功能 3、Visual Basic 6.0有学习版、专业版和企业版,怎样知道所安装的是哪个版本? 答:在启动VB 6.0的启动封面上,能显示对应的版本,见教材例1.1 4、Visual Basic 6.0有多种类型的窗口,若想在设计时看到代码窗口,怎样操作? 答:选择“视图∣代码窗口”命令或“工程资源管理器”窗口的“查看代码”按钮。 5. 叙述建立一个完整的应用程序的过程。 答: a)建立用户界面的控件对象。 b)控件属性的设置。 c)控件事件过程及编程。 d)运行和调试程序。 e)保存程序。 6. 当建立好一个简单的应用程序后,假定该工程仅有一个窗体模块。试问该工程涉及多少个要保存的文件?若要保存该工程中的所有文件,应先保存什么文件,再保存什么文件?若不这样做,系统会出现什么信息? 答:涉及两个文件要保存。先保存窗体文件(.frm),再保存工程文件(.vbp)。若先保存工程文件,系统也会先弹出“文件另存为”对话框,要求先保存窗体文件。 7. 保存文件时,若不改变目录名,则系统默认的目录是什么? 答:系统的默认目录是VB98。 习题二P37 2. 5. 6. 7. 9. 10 参考答案: 2、属性与方法的区别是什么? 答:对象中的数据保存在属性中,VB程序中的对象都有许多属性,它们是用来描述和反映对象特征的参数。可以通过两种方法来设置属性:(1)在设计阶段利用属性窗口直接设置对象的属性值;(2)在程序运行阶段通过赋值语句实现。 方法是附属于对象的行为和动作,也可以理解为指使对象动作的命令。面向对象的程序设计

visualbasic课后答案

第1章参考答案 (1) 第2章参考答案 (1) 第3章参考答案 (4) 第4章参考答案 (7) 第5章参考答案 (9) 第6章参考答案 (13) 第7章参考答案 (16) 第8章参考答案 (20) 第9章参考答案 (22) 第10章参考答案 (27) 第11章参考答案 (28) 第12章参考答案 (31) 第1章参考答案 、简答题(略) 、单选题: 1. C 2. D 3. C 4. B 5 6. D 7. C 三、填空 题: 1 ?设计 运行 2. Proj1 Demo1 3 ?程序代码 控件 4.编译 可执行 5.可视化 6.窗体对象 7.视图 F4 第2章参考答案 一、 简答题(略) 二、 找出以下语句中的错误 1. False ---错,因为False 是VB 的关键字或保留字 2. In tegers —— 错,正确的写法是 dim x ,y ,z as in teger 或 Dim x As Integer, y As Integer, z As Integer 但两者含义不同。 3. a+b=c 改为 c=a+b 4. Mode ----错,应改为mod 5. 37001 ---错,因为 x 取值范围是 432768 ---- 32767 6. +—— —错,应该写为/ 7. ? E - -错,E 的左边必须是一个数字 & 错, 赋值符号的左边字符串缺了双引号 9. 1 --- -错,应改为:” 1 ” 10. 错, 正确的是:#01-01-00# 三、编写语句完成以下任务

1. 设这3个数用x、y、z表示,则求3个数乘积的表达式为:x*y*z 2. Opti on explicit 3. Forml.print “ Print Text to The Windows ” 4. Dim result as long Result=(x+y+z)/3 5. Dim x as in teger, y as in teger, z as in teger 6. Y=3*x A5+2*x A4-6*x A3-1 四、数据常量有:” Xname (字符串型)、True(逻辑型卜517.3(实数型)、 "2/08/05"(日期时间型)、#1-1#(日期时间型)、 ” String (字符串型)、1 (整型) 数据变量有: VB关键 Xname、X Step 五、表达式为: 1.6 2.2002-1-1 3.xyz123abc 4.xyz123abc 5.12 6.11 六.程序段1在窗体上输出为: 5 7 -2 -9 FalseFalse 程序段2在窗体上输出为: Visual The Demo Basic 实验部分 1. 参考代码: Private Sub Form_Click() Dim x As In teger, y As In teger, z As In teger x = InputBox("请输入:") y = InputBox("请输入:") z = InputBox("请输入:") Print x + y + z Print x * y * z Prin t (x + y + z) / 3 End Sub 2. 参考代码和界面如下:

VB教材课后习题答案

<大学程序设计基础-Visual Basic>教材课后习题答案 第1章 一、选择题 1 2 3 4 5 6 7 B D B C B B D 第2章 一、选择题 1 2 3 4 5 6 7 8 9 10 B C B C B C A A A A 11 12 13 14 A B A A 二、填空题 1.rem或’ _ : 2.“” # # 3.5x2-3x-2sinA/3 4.321456 5.300 三、操作题 1、 程序段: Private Sub Command1_Click() Dim x As Integer, y As Integer Dim s As Long, c As Long x = Text1.Text y = Text2.Text s = x * y c = (x + y) * 2 Label3.Caption = "长方形的面积为" + Str(s) Label4.Caption = "长方形的周长为" + Str(c) End Sub 3、 程序段: Private Sub Command1_Click() Text1.Text = "第一" End Sub Private Sub Command2_Click() Text1.Text = "第二" End Sub 4、程序代码: Private Sub Text1_Change() Text1.MaxLength = 10 End Sub 5、程序代码:

Private Sub Text1_Click() Text1.SelStart = 0 Text1.SelLength = Len(Text1.Text) End Sub 第3章 一、选择题 1 2 3 4 5 6 7 D A D B A D B 二、填空题 1. False 2.B^2-4*a*c else 三、操作题 1.从键盘输入三个值,判断它们能否构成三角形的三个边。如果能构成一个三角形,则计算三角形的面积。 Dim a As Integer, b As Long, c As Long, s As Single, p As Single a = Val(InputBox("请输入一个值:")) b = Val(InputBox("请输入一个值:")) c = Val(InputBox("请输入一个值:")) If (a + b > c And a + c > b And b + c > a) Then p = (a + b + c) / 2 s = Sqr(p * (p - a) * (p - b) * (p - c)) Print a & "," & b & "," & c & "能构成一个三角形,它的面积为:" & s End If 2.编写程序,任意输入一个整数,判定该整数奇偶性。 Dim n As Integer n = Val(InputBox("请输入一个整数:")) If n Mod 2 = 0 Then Print n & "是偶数" Else Print n & "是奇数" End If 3.求一元二次方程的a*x^2+b*x+c=0的根。 Dim a As Integer, b As Integer, c As Integer, delta As Single, x1 As Single, x2 As Single a = Val(InputBox("请输入一个整数:")) b = Val(InputBox("请输入一个整数:")) c = Val(InputBox("请输入一个整数:")) delta = b ^ 2 - 4 * a * c If delta = 0 Then x1 = -b / (2 * a) Print "一元二次方程有两个相等的实根x1=x2=" & x1 Else If delta > 0 Then x1 = (-b + Sqr(delta)) / (2 * a) x2 = (-b - Sqr(delta)) / (2 * a)

《VB程序设计》课后题答案

第二章 一、问答题 1.叙述建立一个完整的应用程序的过程。 答:界面设计编写事件过程代码运行、调试保存文件 2.当建立好一个简单的应用程序后,假定该工程仅有一个窗体模块。问该工程涉及到几个文件要保存?若要保存该工程中的所有文件,正确的操作应先保存什么文件?再保存什么文件?若不这样做,系统会出现什么信息? 答:涉及到两个文件要保存。先保存窗体文件(.frm),再保存工程文件(.vbp)。若先保存工程文件,系统也会先弹出“文件另存为”对话框,要求把窗体文件先保存。 3.假定在W indows环境中,要保存工程文件时,若不改变目录名,则系统默认的目录是什么? 答:VB98 4.当标签框的大小由Caption属性的值进行扩展和缩小,应对该控件的什么属性进行何种设置? 答:将标签的Autosize设置为True. 5.VB6.0提供的大量图形文件在哪个目录下?若你的计算机上没有安装,则怎样安装这些图形文件? 答:VB6.0提供的图形文件在Graphics目录。 6.在VB6.0中,命令按钮的显示形式可以有标准和图形两种选择,这通过什么属性来设置?若选择图形的,则通过什么属性来装入图形?若已在规定的属性里装入了某个图形文件,但该命令按钮还是不能显示该图形,而显示的是Caption属性设置的文字,怎样改正?答:按钮Style的属性设置为Graphical(或1)。通过Picture属性来装入图形。不能显示图形是因为Style的属性设置为Standard(或0),只要改为Graphical(或1),一般还将Caption 属性的值设置为空。 7.标签和文本框的区别是什么? 答:文本是否可编辑。 8.当窗体上有三个文本框和一个命令按钮,若程序运行时,需把焦点定位在第三个文本框处,应对何控件的什么属性进行何种设置? 答:应对Text3控件进行Text3.TabIndex=0的设置。 9.简述文本框的change与keypress事件的区别。 答:文本框内容变化,change与keypress事件都会发生,所不同的是Keyprees还将返回一个Keyasii参数 10.当某文本框输入数据后(按了回车键),进行判断认为数据输入错,怎样删除原来数据?怎样使焦点回到该文本框重新输入? 答:假定文本框的名称为Text1,则事件过程如下: Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If 出错条件判断成立Then Text1=””…先删除原来数据 Text1.SetFocus …焦点回到Text1 End If …… End If End Sub

VB部分课后习题答案

1. 选择题 (1) 假定窗体的名称(Name属性)为Form1,则把窗体的标题设置为“VB Test”的语句为(B)。 A. Form1="VB Test" B. Caption="VB Test" C. Form1.Text="VB Test" D. https://www.wendangku.net/doc/1413127012.html,="VB Test" (2) 下列不能打开代码窗口的操作是(D)。 A.双击窗体上的某个控件B.双击窗体C.按F7键D.单击窗体或控件 (3) 为了保存一个Visual Basic应用程序,应当(D)。 A.只保存窗体文件(.frm) B.分别保存工程文件和标准模块文件(.bas) C.只保存工程文件(.vbp) D.分别保存工程文件、窗体文件和标准模块文件 (4) 为了装入一个Visual Basic应用程序,应当(C)。 A.只装入窗体文件(.frm) B.分别装入工程文件和标准模块文件(.bas) C.只装入工程文件(.vbp). D分别装入工程文件、窗体文件和标准模块文件 (5) 不为了使窗体的大小可以改变,必须把它的BorderStyle属性设置为(A)。 A.1 B.2 C.3 D.4 2. 填空题 (1) 在用Visual Basic开发应用程序时,通常首先需要新建工程、其次还要经过、、、和5步。 (2) 控件和窗体的Name属性只能通过属性窗口设置,不能在运行期间设置。 (3) 代码窗口分为左右两栏,左边一栏称为对象,右边一栏称为事件。 (4) 为了在输入程序时能自动进行语法检查,必须执行菜单中的命令,打开对话框,然后选择“编辑器”选项卡中的选项。 (5) 在保存VB应用程序中,窗体文件和工程文件的扩展名分别为 .frm 和.vbp 。 (6) 为了把一个Visual Basic应用程序装入内存,只要装入工程文件即可。 (7) Visual Basic应用程序通常由3类模块组成,即、和。 (8) 在窗体上画两个文本框和一个命令按钮,然后在命令按钮的代码窗口中编写如下事件过程: Private Sub Command1_Click( ) Text1.Text=“VB Programming” Text2.Text=Text1.Text Text1.Text=“ABCD” End Sub 程序运行后,单击命令按钮,两个文本框中显示的内容分别为ABCD 和VB Programming 。

VisualBasic程序设计教程第三版课后习题答案

《VB程序设计》综合复习资料 第一章Visual Basic程序设计概述 一、填空题 1、V isual Basic是一种面向__________的可视化程序设计语言,采取了__________的编程机制。 2、在VB中工程文件的扩展名是____________,窗体文件的扩展名是____________,标准模块文件的扩展名是____________。 3、执行“工程”菜单下的__________命令,可选择并添加ActiveX控件。 4、V isual Basic 6.0用于开发__________环境下的应用程序。 二、选择题 1、下面不是VB工作模式的是() A.设计模式B.运行模式C.汇编模式D.中断模式 2、可视化编程的最大优点是() A.具有标准工具箱 B.一个工程文件由若干个窗体文件组成 C.不需要编写大量代码来描述图形对象 D.所见即所得 3、下列不能打开属性窗口的操作是() A.执行“视图”菜单中的“属性窗口”命令 B.按F4键C.按Ctrl+T D.单击工具栏上的“属性窗口”按钮 4、下列可以打开立即窗口的操作是() A.Ctrl+D B.Ctrl+E C.Ctrl+F D.Ctrl+G 5、V isual Basic的编程机制是() A.可视化B.面向对象C.面向图形D.事件驱动 三、简答题 1、代码窗口主要包括哪几部分?

2、在工程资源管理器窗口中,主要列出了哪三类文件? 3、窗体布局窗口的主要用途是什么? 4、VB的基本特点是什么? 5、怎样理解可视化设计? 6、怎要理解事件驱动编程? 第二章简单的VB程序设计 一、填空题 1、设置是否可以用Tab键来选取命令按钮,应该用______________属性。 2、一个控件在窗体的位置由_______和________属性决定,其大小由__________和_________属性决定。 3、利用对象的属性setfocus可获得焦点,对于一个对象,只有其visible属性和____________属性为true,才能接受焦点。 4、设置控件背景颜色的属性名称是______________________。 5、所有控件都具有的共同属性是__________________属性。 6、一般情况下,控件有两个属性项的缺省值是相同的,这两个属性项是_______________。 7、VB中的每个对象(控件)都有一组特征,这组特征称为__________,我们通过修改它可以控制对象的外观和操作。 8、通常情况下,VB中一个工程主要包括如下四个文件:窗体文件、工程文件、类模块文件和_____________文件,后者的扩展名为.Bas,通常由Basic语言编写,是一个可共用的子程序。 9、VB有三种工作模式,分别是设计(Design)模式、_____________和中断(Break)模式。 二、选择题 1、以下能够触发文本框Change事件的操作是() A.文本框失去焦点B.文本框获得焦点 C.设置文本框的焦点D.改变文本框的内容 2、应用程序设计完成后,应将程序保存,保存的过程是() A.只保存窗体文件即可 B.只保存工程文件即可

VB教材习题参考答案

教材习题的参考答案 第1章 选择题 1 C 2 A 3 A 4 C 5 B 6 C 7 D 8 A 9 D 10 C 填空题 1.对象Windows 事件驱动 2.窗体工程 3.查看对象查看代码 4.CmdExam Click lbldisp 5.工具栏“启动”按钮菜单命令“运行|启动”F5键 6.命令按钮 7.Cancel 8.Label1 第2章 一、选择题 1 A 2 C 3 D 4 B 5 C 6 A 7 B 8 A 9 B 10 D 二、写出下列表达式的值 1、4 2、0 3、8 4、False 5、False 6、True 7、-1 8、16.7 9、“C”10、“Basic”11、“VISUAL ”12、5 三、将下列数学表达式改写成Visual Basic表达式 1、(a + b) / (c * d - Sqr(1 - a *a )) + 5^(1/3) * Cos(60*3.14/180) * Cos(60*3.14/180) 2、Sin(45 * 3.14159 / 180) + Abs(x - y) 3、2 * Exp(x) + Log(x * y) 4、(Log(50)/Log(10)-Log(20))/(9*Exp(3)) 5、Abs(X)>=Y and Abs(X)<>Z 6、M<100 And M>=0 7、A Mod 3 =0 Or A Mod 7 =0 8、N Mod 4 =0 And N Mod 100 <> 0 Or N Mod 400 = 0 第3章(P74) 选择题 1 CD 2 B 3 B 4B 5 C 6 A 7 D 8 BD 9 C 10 C 11 A 12 A 13 D 14 A 15 A 16 D 填空题 1. 出错 2. x=3 y=10 3. 4. 12345 54321;将数值a转换成字符串,并逆序输出 5. ABCDE 6. 32 7. (1)k (2)If x < n Then n = x: nk = i (3)mk (4) m

VB课后习题第11章习题及答案

习题十一及答案 习题十一 1.简答题 (1)Visual Basic有哪几种工作模式? (2)Visual Basic中错误类型有哪几种? (3)简要说明VB程序调试的主要方法和工具。 (4)“立即”窗口、“监视”窗口和“本地”窗口有什么区别? 2.判断题 (1)在VB集成环境中只有运行程序才能发现程序错误。 ( ) (2)设置错误的捕捉陷阱,指在程序中可能出现错误的地方放置捕捉语句来捕获产生错误的语句。 ( ) (3)On Error Resume Next语句的功能是忽略错误,继续往下执行。 ( ) (4)VB程序中出现编译错误时,不会产生错误提示。 ( ) 3.选择题 (1)当语句不符合文法规则时,出现的错误是()。 A)逻辑错误 B)运行时期错误 C)语法错误 D)以上都不对 (2)下列陈述中正确的是()。 A)中断点只能在设计过程中设置。 B)中断点只能在执行过程中设置。 C)中断点可以在设计过程或在执行过程中设置。 D)中断点可以在设计过程中设置,也可以在执行过程或中断过程中设置。 (3)下列属性中,属于Err对象的有()。 A) Number B) Caption C) Description D) Text 4.填空题 (1)设置断点的快捷键是。 (2)VB单步执行的快捷键是。 (3)错误码为11时表示发生的错误是。 5.编写一段程序,如果出现数组下标越界时,则给出错误的描述并结束程序的运行。 习题十一参考答案: 一、简答题 1.Visual Basic有哪几种工作模式? (1)设计模式 启动Visual Basic后,即进入设计模式,在主窗口标题栏上显示“设计”字样。建立一 个应用程序的所有步骤基本上都在设计模式下完成,包括窗体设计、建立控件、编写程序代 码以及利用属性窗口设置属性值或查看当前属性值等。但在设计阶段不能执行程序,也不能 使用调试工具,只可设置断点。 应用程序可以直接从设计阶段进入运行阶段,但不可以进入中断模式。 (2)执行模式 执行“运行”菜单中的“启动”命令(或按下F5键、或单击工具条上的“启动”按钮), 即进入执行模式,此时标题栏上原来显示“设计”的地方已被“运行”字样所代替。当整个 应用程序进入运行阶段后,开始执行程序代码。在运行阶段只可以执行代码,不能修改代码。 (3)中断模式

vb课后答案(1)

1.通过文本框TextBook1舒服一个实数,单击计算按钮,在TextBook2-6中分别输出该数的相反数,平方,绝对值平方根,立方以及绝对值的立方根。需要在文本框前添加注释文本框内的数据。 Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x As Single x = TextBox1.Text TextBox2.Text = -x TextBox3.Text = x ^ 2 TextBox4.Text = System.Math.Sqrt(System.Math.Abs(x)) TextBox5.Text = x ^ 3 TextBox6.Text = (System.Math.Abs(x)) ^ (1 / 3) End Sub End Class 2.使用文本框Textbook1和Textbook2分别输入两个数,给变量X和Y赋值,单击交换按钮变换按钮,交换extbook1和Textbook2中的内容。 Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x, y, t As Integer x = TextBox1.Text y = TextBox2.Text t = x x = y y = t TextBox1.Text = x TextBox2.Text = y

VB书后习题解答新教材B

作业一 1.VB是用于开发________环境下应用程序的工具。(B) A. DOS B. Windows C. DOS和Windows D. UNIX 2.VB6.0是________位操作系统下的应用程序开发工具。(A) A. 32 B. 16 C. 32或16 D. 64 3.一个对象可执行的动作与可被一个对象所识别的动作分别称为________(B) A.事件、方法 B.方法、事件 C.属性、方法 D.过程、事件 4.有一个红色、充满氢气的气球,如果人不小心松开手抓的引线,就会飞走;如果用针刺它,则会爆破。 请问,对于气球对象,哪些是属性、哪些是事件、哪些是方法? 答:属性是红色、氢气;事件是松开、针刺;方法是飞走、爆破。 5.VB的集成开发环境都有哪些元素些组成? 答:VB的集成开发环境由标题条、菜单条、弹出式菜单(上下文菜单)、工具栏、控件工具箱、初始窗体、工程资源管理器子窗口、属性子窗口、窗体布局子窗口、代码编辑器窗口、立即、本地和监视窗口等。 6.简述用VB开发应用程序的一般步骤? 答:VB开发应用程序的一般步骤是: ①创建程序的用户界面; ②设置界面上各个对象的属性; ③编写对象响应事件的程序代码; ④保存工程; ⑤测试和调试应用程序,检查并排除程序中的错误; ⑥创建可执行程序。

作业二 2.以下窗体名中哪些是非法的窗体名?(A B D E) A. _aform B. 3frm C. f_1 D. frm 5 E. f_1* 6.有程序代码如下:Form2.Caption=”Help”,试问:Form2、Caption和Help分别代表______ (C) A.对象、值、属性 B.值、属性、对象 C.对象、属性、值 D.属性、对象、值 7.VB的常用控件中,哪些控件具有Caption属性,而没有Text属性?哪些控件具有Text属性,却没有Caption属性? 答:具有Caption属性而没有Text属性的控件有:标签、命令按钮、复选框、选项按钮、框架;具有Text属性而没有Caption属性的控件有:文本框、组合框、列表框。 8.对象的属性是否只能在设计界面时在属性窗口中进行设置?属性窗口中的属性列表是否包括了一个对象的所有属性? 答:属性的设置既可以在属性窗口中进行设置,也可以在程序代码中进行设置,但有些对象的有些属性只能在属性窗口中进行设置,如文本框的多行属性,有些对象的有些属性只能在程序代码中进行设置,如列表框的列表项数目属性;属性窗口中的属性列表中不包括一个对象的所有属性,如列表框的ListIndex属性、ListCount属性就不在属性列表中。 9.除窗体之外,还有哪些控件可作为其他控件的容器使用? 答:还有:框架、图片框 10.常用控件中具有Value属性的控件有哪些?它们的取值及类型有何异同? 答:常用控件中具有Value属性的控件有:选项按钮、复选框、滚动条;选项按钮的取值为逻辑型,选中该选项按钮时,其值为True,未选中该选项按钮时,其值为False;复选框的取值为数值型,选中该复选框时,其值为1,未选中该复选框是,其值为0,复选框变灰时,其值为2;滚动条的取值为数值型,其值为滚动块在滚条中的位置。 12.以下使用方法的代码中,正确的是________ (C) A. Label1.SetFocus B. Form1.Clear C. Text1.SetFocus D. Combo1.Cls

相关文档
相关文档 最新文档