资源描述:
《晓英振辉奇葩计算机》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、(红色加粗是检索词,绿色是备注)PublicClassForm1PrivateSubForm1_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMe.ClickDimvar1AsInteger,var2AsStringvar1=12345var2=InputBox("输入Var2=","输入对话框")MsgBox(var2&Chr(13)+Chr(10)&"var1="&Str(var1))'MsgBox(var2&vbCrLf&"var1="&Str(var1))EndSubEndClass定义不同
2、变量PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimaAsShort‘短型DimbAsSingle‘单精度DimcAsInteger‘整型DimdAsDateDime1AsStringDimfAsBoolean‘判断DimgAsStringDimhAsDouble‘双精度DimiAsSingleDimj(4,3)AsIntegera=3.25b=546.2c=5383149d=#12/31
3、/2003#e1="ABCDEF"f=Falseg="123456"h=3.24E+100i=1.2563E+15j(0,0)=456MsgBox(a&vbCrLf&b&vbCrLf&c&vbCrLf&d&vbCrLf&e1&vbCrLf&f&vbCrLf&g&vbCrLf&h&vbCrLf&i&vbCrLf&j(0,0))EndSub分析不同表达式,定义并输出结果PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickDimx21,
4、x22,x23,x24AsSingleDimx25,x27,x28AsBooleanDimx26AsStringx21=Sqrt(3^2/(2*4))‘开方x22=+Abs(0.123-3)‘绝对值x23=-Sin(30)x24=Exp(6)+Log(2.135)‘e的6次方x25=89&12<>8912x26="AB"+Str(32.56)+"CD"'x27=Mid("student",5)="ent"And(5>2)‘右边数三位x27=Microsoft.VisualBasic.Right("student",3)="ent"And(5>2)x28=Not(6>2
5、)Or(7<9)MsgBox(x21&vbCrLf&x22&vbCrLf&x23&vbCrLf&x24&vbCrLf&x25&vbCrLf&x26&vbCrLf&x27&vbCrLf&x28)EndSub一百以内随机数PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickDimyAsIntegery=Int(Rnd()*100)MsgBox(y)EndSub任意字符串测长度PrivateSubButton4_Click(ByVals
6、enderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton4.ClickDimyAsStringDimy1AsIntegery="VB程序设计语言"y1=Len(y)MsgBox(y&"长度为"&y1)EndSub给出字符串查片段位置PrivateSubButton5_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton5.ClickDimyAsIntegery=InStr("abcstudent","stu")MsgB
7、ox(y)EndSub除去字符串两边空格PrivateSubButton6_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton6.ClickDimyAsStringy=Trim("VisualC++")MsgBox("去除左边空格"&y&"去除右边空格")EndSub测字符串所占字节数PrivateSubButton7_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton