【VB开源代码栏目提醒】:网学会员--在 VB开源代码编辑为广大网友搜集整理了:VB程序设计教程(第3版)课后实验答案 - 计算机绩等信息,祝愿广大网友取得需要的信息,参考学习。
A.1Private Sub Command1_Click Label3 Text1End SubA.2Private Sub Form_Load Timer1.Interval 0End SubPrivate Sub Command1_Click 自动 Timer1.Interval 200End SubPrivate Sub Command2_Click 手动 Timer1.Interval 0 Call MyMoveEnd SubPrivate Sub Timer1_Timer Call MyMoveEnd SubSub MyMove Label1.Move Label1.Left - 50 If Label1.Left lt 0 Then Label1.Left Form1.WidthEnd SubA.3Private Sub Form_Click Text1 ValText1 1End SubPrivate Sub Form_Load Text1 0End SubA.4Private Sub Form_Click Caption quot单击窗体,改变图片quot Picture LoadPictureApp.Path quotn_015.bmpquot Print quot欢迎使用 VBquotEnd SubPrivate Sub Form_DblClick Cls Caption quot双击窗体,卸去图片quot Picture LoadPicturequotquot End SubPrivate Sub Form_Load Caption quot装入窗体quot Picture LoadPictureApp.Path quotn_016.bmpquot Print quot装入图quotEnd SubPrivate Sub Form_Resize 该事件的作用窗体始终与图一样大 Caption quot窗体大小不变quot Form1.Width 260 16 260 是 Tongji-2.bmp 图的宽度,象素单位 Form1.Height 260 16 200 260 是图的高度,象素单位,200 是窗体的标题栏高度End SubA.5Sub Command1_Click Text1.FontName quot隶书quot Text1.FontSize 25End SubSub Command2_Click Text2.Text Text1.SelText Text2.FontName Text1.FontName Text2.FontSize Text1.FontSizeEnd SubB.1Private Sub Command1_Click Text2 Format5 / 9 ValText1 - 32 quot0.00quotEnd SubPrivate Sub Command2_Click Text1 Format9 / 5 ValText2 32 quot0.00quotEnd Sub或Private Sub Command1_Click Dim f c 声明两个变量 f ValText1 c 5 / 9 f - 32 Text2 Formatc quot0.00quot 保留两位小数End SubPrivate Sub Command2_Click Dim ff cc 声明两个变量 cc ValText2 ff 9 / 5 cc 32 Text1 Formatff quot0.00quot 保留两位小数End SubB.2Private Sub Command1_Click Label2 FormatValText1 ValText1 3.14 quot0.00quotEnd SubPrivate Sub Command2_Click Label3 FormatValText1 3.14 2 quot0.00quotEnd SubPrivate Sub Text1_LostFocus If Not IsNumericText1.Text Then MsgBox quot输入有非数字字符,请重新输入quot quot警告quot Text1.Text quotquot Text1.SetFocus End IfEnd Sub或Private Sub Command1_Click Label2 FormatValText1 ValText1 3.14 quot0.00quotEnd SubPrivate Sub Command2_Click Label3 FormatValText1 3.14 2 quot0.00quotEnd SubPrivate Sub Text1_KeyPressKeyAscii As Integer If KeyAscii 13 Then If Not IsNumericText1.Text Then Text1.Text quotquot End If End IfEnd SubB.3Private Sub Command1_Click n IntLog2 / Log1.008 1 Label1 n amp quot年后人数超过 26 亿quotEnd SubB.4Private Sub Command1_Click Dim x dx cd x Text1.Text dx UCasex cd Lenx Print quot大写字母为:quot dx Print quot字符串长度为:quot cdEnd SubB.5Private Sub Command1_Click Text1 IntRnd 900 100End SubPrivate Sub Command2_Click Dim x x1 x2 x3 x ValText1 x1 x Mod 10 分离出的个位数 x2 x Mod 100 10 分离出的十位数 x3 x 100 分离出的百位数 Label1 x1 100 x2 10 x3End SubB.6Private Sub Form_Click Label1 LeftText1 11 Label2 MidText1 12 6 Label3 RightText1 5End SubB.7Private Sub Command1_Click Print For i 1 To 5 Print Tab15 - i 2 String2 i - 1 quot★quot Spc18 - 4 i - 1 String2 i - 1 quot★quot Next iEnd SubPrivate Sub Command2_Click ClsEnd Sub进一步要求:Private Sub Command1_Click Print For i 1 To 5 Print Tab15 - i 2 String2 i - 1 quot★quot String10 - 2 i - 1 quot☆quot String2 i - 1 quot★quot Next iEnd SubPrivate Sub Command2_Click ClsEnd SubB.8Private Sub Form_Clickx ValInputBoxquot输入一正实数quot quot计算quot 0pf Formatx x quot0.000quotpfg FormatSqrx quot0.000quotlf Formatx x x quot0.000quotlfg Formatx 1 / 3 quot0.000quotPrint quot平方为:quot pf Space5 quot平方根为:quot pfg Space5 quot立方为:quot lf Space5 quot立方根为:quotlfgEnd SubC.1Private Sub Form_ClickDim x yx ValInputBoxquot输入 x 的值quotIf x lt 1000 ThenyxElseIf x lt 2000 Theny 0.9 xEls