欢迎来到天天文库
浏览记录
ID:37913794
大小:76.50 KB
页数:27页
时间:2019-06-02
《VB程序设计基础例题》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、3.1交换变量a1、a2的值,P35PrivateSubForm_Click()Dima1AsInteger,a2AsInteger,tAsIntegera1=5:a2=10Form1.Print"交换";a1;a2t=a1:a1=a2:a2=tForm1.Print"得:";a1;a2EndSubPrivateSubForm_Load()Form1.AutoRedraw=TrueForm1.Print"交换两个数"Form1.Print"单击窗体开始"EndSub3.2Tab函数,P35PrivateSubForm_Click()Form1.PrintTab(10);
2、"*********"Form1.PrintTab(11);"*******"Form1.PrintTab(12);"*****"Form1.PrintTab(13);"***"Form1.PrintTab(14);"*"EndSubPrivateSubForm_Load()Form1.AutoRedraw=TrueForm1.Print"显示星号三角形,单击窗体开始"EndSub3.5Move方法在指定位置显示窗体,文本框和图,P45PrivateSubForm_Load()Picture1.AutoRedraw=TrueMove3000,2000,2800,2800
3、Text1.Move300,200,2000,500Picture1.Move300,1000,1600,1200Text1.Text="文本框"Picture1.Print"图片框"EndSub图3.13显示和隐藏,P46PrivateSubForm_Click()Form1.HideForm2.ShowEndSubPrivateSubForm_Load()AutoRedraw=TrueForm1.Print"单击显示form2"EndSubPrivateSubForm_dblClick()Form2.HideForm1.ShowEndSubPrivateSubFor
4、m_Load()AutoRedraw=TrueForm2.Print"双击显示form1"EndSub3.6输出位置以及字体设置,P46PrivateSubForm_Load()AutoRedraw=TrueForm1.Width=Screen.Width/2Form1.Height=Screen.Height/3Form1.Left=(Screen.Width-Form1.Width)/2Form1.Top=(Screen.Height-Form1.Height)/2FontName="黑体":FontSize=20str1$="VisualBasic应用程序"Cur
5、rentX=(Form1.Width-TextWidth(str1$))/2CurrentY=(Form1.Height-TextHeight(str1$))/3Form1.Printstr1$EndSub3.12InputBox及“+”的应用P53PrivateSubForm_Click()a=InputBox("enteraninteger",123,456,,,HelpFile,context)b=InputBox("enteraninteger")Text1.Text=b+aEndSub3.11计时器,P52Rem“计时开始”按钮单击事件PrivateSubCo
6、mmand1_Click()Text1.Text="计时开始"Form1.Tag=TimerCommand1.Enabled=FalseCommand2.Enabled=TrueEndSubRem“计时停止”按钮单击事件PrivateSubCommand2_Click()Text1.Text=CInt(10*(Timer-Form1.Tag))/10Command1.Enabled=TrueCommand2.Enabled=FalseEndSubRem“结束”按钮单击事件PrivateSubCommand3_Click()EndEndSubRem窗体装载事件作初始化Pr
7、ivateSubForm_Load()Text1.Text="计时器"Command2.Enabled=FalseTimer1.Interval=100EndSubRem计时器控制事件由interval属性设置的时间间隔触发PrivateSubTimer1_Timer()Label1.Caption=Time$EndSub3.13计算平方根,P55PrivateSubForm_Click()DimintFlagAsIntegerDimstrNumberAsStringDimstrMSGAsStringstrNumber=InputBox(
此文档下载收益归作者所有