资源描述:
《vb编程实例2013》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、实验30(1)PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimaAsString,bAsString,cAsStringDimx1AsSingle,x2AsSinglea=InputBox("输?入?A","输?入?数簓据YY",,500,500)b=InputBox("输?入?B","输?入?数簓据YY",,500,500)c=InputBox("输?入?C","输?
2、入?数簓据YY",,500,500)x1=-b+Math.Sqrt(b^2-4*a*c)/2/ax2=-b-Math.Sqrt(b^2-4*a*c)/2/aMsgBox("x1="&Format(x1,"###.###")&"x2="&Format(x2,"###.###"))EndSubPrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickDimxAsSingleDimyAsSinglex=InputBox("
3、输?入?x")y=Math.Log(20)+Math.Abs(x-16)MsgBox("Math.Log(20)+Math.Abs(x-16)="&y)EndSub计算落体PrivateSubButton5_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton5.ClickConstgAsSingle=9.81DimvAsSingle,oAsSingle,tAsSingle,sAsSinglev=InputBox("输?入?初?速ù度è")o=InputBox
4、("输?入?角?度è")t=2*v*Math.Sin(o*Math.PI/180)/gs=v*Math.Sin(2*o*Math.PI/180)/gMsgBox("落?地?所ù需è时骸?间?"&t&"落?地?时骸?运?动ˉ的?射?程ì"&s)EndSubEndClass实验30(2)随机产生奇偶数并输出PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimxAsInteger
5、x=Int(Rnd()*100)IfxMod2=0ThenMsgBox(x&"是?偶?数簓")ElseMsgBox(x&"是?奇?数簓")EndIfEndSub比较三个数的大小并输出PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickDimaAsSingle,bAsSingle,cAsSingle,xAsSingle,yAsSinglea=InputBox("请?输?入?a")b=InputBox("请?输?入
6、?b")c=InputBox("请?输?入?c")Ifa>bThenx=ay=bElsex=by=aEndIfIfc>aThenx=cElseIfc7、请?输?入?t")Ift<120Thenf=0.06*t+2MsgBox("f=0.06*t+2="&f)Elsef=0.06*t*0.85MsgBox("f=0.06*t*0.85="&f)EndIfEndSub判断成绩等级PrivateSubButton4_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton4.ClickDimxAsSingleDimyAsStringx=InputBox("请?输?入?成é绩¨")Ifx>=90Theny="A"Else
8、Ifx>=80Theny="B"ElseIfx>=70Theny="C"ElseIfx>=60Theny="D"Elsey