VB实验程序代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

实验二实验2.1PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadlb_h.Text=华氏温度lb_c.Text=摄氏温度tx_h.Text=tx_c.Text=bn_htoc.Text=华氏转摄氏bn_ctoh.Text=摄氏转华氏EndSubPrivateSubbn_htoc_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_htoc.ClickDimh,cAsSingleh=Val(tx_h.Text)c=5/9*(h-32)tx_c.Text=Format(c,0.##)EndSubPrivateSubbn_ctoh_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_ctoh.ClickDimh,cAsSinglec=Val(tx_c.Text)h=9/5*c+32tx_h.Text=Format(h,0.##)EndSub'以下可以不看Subtx_handle(ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Ife.KeyChar=0Ande.KeyChar=9ThenExitSubEndIfIfAsc(e.KeyChar)=8OrAsc(e.KeyChar)=46ThenExitSubEndIfIfAsc(e.KeyChar)=45ThenExitSubEndIfe.Handled=TrueEndSubPrivateSubtx_c_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Handlestx_c.KeyPresstx_handle(e)EndSubPrivateSubtx_h_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Handlestx_h.KeyPresstx_handle(e)EndSub实验2.2PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadlb_y.Text=人民币lb_v.Text=兑换比率lb_s.Text=美元tx_y.Text=tx_v.Text=tx_s.Text=bn_cls.Text=清屏bn_ytos.Text=¥→$bn_stoy.Text=$→¥bn_end.Text=结束Me.Text=人民币与美元兑换EndSubPrivateSubbn_cls_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_cls.Clicktx_y.Text=tx_v.Text=tx_s.Text=EndSubPrivateSubbn_ytos_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_ytos.ClickDims,y,vAsSingley=Val(tx_y.Text)v=Val(tx_v.Text)s=y*vtx_s.Text=Format(s,0.##)EndSubPrivateSubbn_stoy_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_stoy.ClickDims,y,vAsSingles=Val(tx_s.Text)v=Val(tx_v.Text)Ifv0Theny=s/vElseMsgBox(兑换比率不能为零!,MsgBoxStyle.OKOnly,错误)EndIftx_y.Text=Format(y,0.##)EndSubPrivateSubbn_end_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_end.ClickEndEndSub'以下可以不看PrivateSubtx_s_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Handlestx_s.KeyPresstx_handle(e)EndSubPrivateSubtx_v_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Handlestx_v.KeyPresstx_handle(e)EndSubPrivateSubtx_y_KeyPress(ByValsenderAsObject,ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Handlestx_y.KeyPresstx_handle(e)EndSubSubtx_handle(ByValeAsSystem.Windows.Forms.KeyPressEventArgs)Ife.KeyChar=0Ande.KeyChar=9ThenExitSubEndIfIfAsc(e.KeyChar)=8OrAsc(e.KeyChar)=46ThenExitSubEndIfe.Handled=TrueEndSub实验2.3PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadlb_in.Text=输入圆半径tx_r.Text=12'默认值tx_s.Text=tx_l.Text=bn_s.Text=圆面积bn_l.Text=圆周长EndSubPrivateSubbn_s_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_s.Click'IfNoterror_handle()Then'ExitSub'EndIfIfNotIsNumeric(tx_r.Text)ThenMsgBox(请输入数字!,MsgBoxStyle.OKOnly,错误)ExitSubEndIfIfVal(tx_r.Text)0ThenMsgBox(请输入正数!,MsgBoxStyle.OKOnly,错误)ExitSubEndIfDimsAsSingles=Math.PI*Val(tx_r.Text)^2tx_s.Text=Format(s,0.##)EndSubPrivateSubbn_l_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_l.Click'IfNoterror_handle()Then'ExitSub'EndIfIfNotIsNumeric(tx_r.Text)ThenMsgBox(请输入数字!,MsgBoxStyle.OKOnly,错误)ExitSubEndIfIfVal(tx_r.Text)0ThenMsgBox(请输入正数!,MsgBoxStyle.OKOnly,错误)ExitSubEndIfDimlAsSinglel=2*Math.PI*Val(tx_r.Text)tx_l.Text=Format(l,0.##)EndSub'以下可以不看Functionerror_handle()AsBooleanerror_handle=TrueIfNotIsNumeric(tx_r.Text)ThenMsgBox(请输入数字!,MsgBoxStyle.OKOnly,错误)error_handle=FalseExitFunctionEndIfIfVal(tx_r.Text)0ThenMsgBox(请输入正数!,MsgBoxStyle.OKOnly,错误)error_handle=FalseExitFunctionEndIfEndFunction实验2.4PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadlb_login.Text=用户登录lb_user.Text=请输入用户名lb_psw.Text=请输入你的密码tx_user.Text=hellotx_psw.Text=tx_psw.PasswordChar=*tx_psw.MaxLength=10tx_user.MaxLength=10EndSubPrivateSubForm1_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMyBase.ClickIfNot(IsNumeric(tx_psw.Text)AndVal(tx_psw.Text)0)ThenMsgBox(密码必须是数字!,MsgBoxStyle.OKOnly,错误)ExitSubEndIfIftx_psw.Text123456ThenMsgBox(密码输入错误!,MsgBoxStyle.OKOnly,错误)ExitSubEndIfMsgBox(登录成功!,MsgBoxStyle.OKOnly,错误)Shell(spider.exe)'打开当前目录下的游戏EndSub实验三实验3.2PrivateSubForm1_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Loadlb_x.Text=xlb_y.Text=ylb_z.Text=ztx_x.Text=tx_y.Text=tx_z.Text=tx_rs.Text=lb_rs.Text=排序结果bn_sort.Text=排序bn_cls.Text=清空bn_end.Text=结束Me.Text=三个数排序tx_rs.ReadOnly=TrueEndSubPrivateSubbn_cls_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_cls.Clicktx_x.Text=tx_y.Text=tx_z.Text=tx_rs.Text=EndSubPrivateSubbn_end_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_end.ClickEndEndSubPrivateSubbn_sort_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handlesbn_sort.ClickDimx,y,z,tAsSinglex=Val(tx_x.Text)y=Val(tx_y.Text)z=Val(tx_z.Text)IfxyThent=x:x=y:y=tEndIfIfxzThent=x:x=z:z=tEndIfIfyzThent=z:z=y:y=tEndIftx_rs.Text&=x&&y&&z&vbNewLineEndSub'以下可以不看Subtx_handle(ByValeAsSystem.Win

1 / 28
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功