您好,欢迎访问三七文档
“高考倒计时”程序设计文档一、程序名称:高考倒计时二、程序功能1:显示当前时间、高考时间、剩余时间三、程序设计1:标签控件:Label12:文本控件:Text13:定时器控件:Timer1四、程序实现1:窗体加载:SubForm_Load()2:最大化:Me.WindowState=vbMaximized3:根据窗口宽度、高度设置字体大小:F=Me.ScaleX(Me.ScaleWidth,Me.ScaleMode,3)/(S0*2+S1+S2)H=Me.ScaleY(Me.ScaleHeight,Me.ScaleMode,3)/124:默认时间为计算机当前年份的6月7日:IfnStr=ThenY=Format(Date,yyyy)I=DateDiff(s,Now,Y&-6-79:00:00)IfI0ThenY=Y+1nStr=Y&-6-79:00:005:计时器:Timer1_Timer()五、程序运行六、程序代码DimctStrAsStringPrivateSubForm_Load()DimIAsLong,YAsLong,nStrAsStringctStr=Trim(GetSetting(xUnTime,xOpt,xCap,))IfctStr=ThenctStr=高考'默认标题Text1.Font.Bold=TrueLabel1(0).AutoSize=True:Label1(0).Font.Bold=TrueLabel1(0).BackStyle=0ForI=1To5LoadLabel1(I):Label1(I).Visible=TrueNextMe.BackColor=&HFF8888Label1(0).ForeColor=&HFF0000Label1(0).ToolTipText=单击可修改标题nStr=Trim(GetSetting(xUnTime,xOpt,xTime,))IfnStr=Then'默认时间:为计算机当前年份的6月7日Y=Format(Date,yyyy)I=DateDiff(s,Now,Y&-6-79:00:00)IfI0ThenY=Y+1nStr=Y&-6-79:00:00EndIfText1.MaxLength=20:Text1.Text=nStrTimer1.Enabled=True:Timer1.Interval=1000Me.WindowState=vbMaximized'最大化EndSubPrivateSubForm_Unload(CancelAsInteger)SaveSettingxUnTime,xOpt,xCap,ctStrSaveSettingxUnTime,xOpt,xTime,Text1.TextEndSubPrivateSubLabel1_Click(IndexAsInteger)'用户修改标题IfIndex0ThenExitSubDimnStrAsStringnStr=Trim(InputBox(请输入倒计时事件的标题:,倒计时-设置标题,ctStr))IfRight(nStr,3)=倒计时ThennStr=Trim(Left(nStr,Len(nStr)-3))IfnStr=ThenExitSubctStr=nStrCallForm_ResizeEndSubPrivateSubText1_Change()CallTimer1_TimerCallForm_ResizeEndSubPrivateSubForm_Resize()DimIAsLong,HAsSingle,FAsSingle,W1AsSingleDimS0AsSingle,S1AsSingle,S2AsSingle,L1AsSingle,L2AsSingleS0=0S1=5+LenB(StrConv(ctStr,vbFromUnicode))IfS19ThenS1=9S2=0.5+LenB(StrConv(Text1.Text,vbFromUnicode))IfS216.5ThenS2=16.5F=Me.ScaleX(Me.ScaleWidth,Me.ScaleMode,3)/(S0*2+S1+S2)'根据窗口宽度设置字体大小H=Me.ScaleY(Me.ScaleHeight,Me.ScaleMode,3)/12'根据窗口高度设置字体大小IfFHThenF=HF=F-1IfF3ThenF=3Text1.Font.Size=Fhh=Text1.Font.SizeSetMe.Font=Text1.FontW1=Me.TextWidth(A)L1=(Me.ScaleWidth-W1*(S1+S2))*0.5L2=L1+W1*S1Text1.Width=W1*S2Label1(0).Font.Size=F*1.5ForI=1ToLabel1.UBoundLabel1(I).Font.Size=FNextH=Label1(1).Height*0.5'标题Me.Caption=ctStr&倒计时Label1(0).Caption=ctStr&倒计时Label1(0).Move(Me.ScaleWidth-Label1(0).Width)*0.5,(Me.ScaleHeight-H*12)*0.4'当前时间Label1(1).Caption=当前时间Label1(1).MoveL1,Label1(0).Top+H*4.5:Label1(2).MoveL2,Label1(1).Top'高考时间Label1(3).Caption=ctStr&时间Label1(3).MoveL1,Label1(1).Top+H*3Text1.Appearance=0Text1.MoveL2,Label1(3).Top,Text1.Width,Label1(3).Height'剩余时间Label1(4).MoveL1,Label1(3).Top+H*3:Label1(4).Caption=剩余时间Label1(5).MoveL2,Label1(4).Top:Label1(5).ForeColor=255EndSubPrivateSubTimer1_Timer()DimDAsLong,HAsLong,MAsLong,SAsLongOnErrorGoTocuoLabel1(2).Caption=NowS=DateDiff(s,Now,CDate(Text1.Text))IfS1ThenLabel1(5).Caption=时间到:ExitSubD=S\86400'3600*24S=SMod86400:H=S\3600S=SMod3600:M=S\60S=SMod60Label1(5).Caption=D&天&H&时&M&分&S&秒ExitSubcuo:Label1(5).Caption=输入的时间错误EndSub
本文标题:高考倒计时VB
链接地址:https://www.777doc.com/doc-4992488 .html