资源描述:
《圆周率VB程序代码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、VERSION5.00BeginVB.FormForm2Caption="圆周率_十位一组计算的"ClientHeight=2775ClientLeft=45ClientTop=300ClientWidth=6600Icon="圆周率.frx":0000LinkTopic="Form1"ScaleHeight=2775ScaleWidth=6600StartUpPosition=3'窗口缺省BeginVB.TextBoxText1Height=2124Left=0Locked=-1'TrueMultiLine
2、=-1'TrueScrollBars=2'VerticalTabIndex=2Top=585Width=6576EndBeginVB.CommandButtoncmdendCaption="退出"Height=364Left=2040TabIndex=1Top=117Width=1066EndBeginVB.CommandButtoncmdstartCaption="开始"Height=364Left=371TabIndex=0Top=117Width=1066EndBeginVB.LabelLb1Heigh
3、t=372Left=3480TabIndex=3Top=120Width=3012EndEndAttributeVB_Name="Form2"AttributeVB_GlobalNameSpace=FalseAttributeVB_Creatable=FalseAttributeVB_PredeclaredId=TrueAttributeVB_Exposed=FalseOptionExplicitPrivateSubCmdend_Click()UnloadMeEndSubPrivateSubcmdstart_
4、Click()Dima1AsDouble,b1AsDouble,b2AsDouble,c1AsDoubleDimnAsDouble,dAsDouble,gAsDouble,XAsDoubleDima()AsDouble,b()AsDouble,c()AsDoubleConstrAsDouble=10000000000#ConstStr3AsString="0000000000"DimstrS1AsStringDimtime1AsDoubleDimiAsLong,qAsLong,kAsLong,mAsLong,
5、jAsLongDimpAsLongDop=Val(InputBox("请输入要计算位数","输入","10"))+1LoopUntilp>0'cmdstart.Enabled=Falsetime1=TimerReDima(1Top),b(1Top),c(1Top)b(1)=4*5*rc(1)=239*r:i=1:q=-1:k=1:m=1Doq=-q:a1=0:b1=0:c1=0Forj=mTopc1=c1*r+c(j):c(j)=Int(c1/57121)c1=-57121*c(j)+c1NextjIfc(m
6、)=0Thenm=m+1Forj=kTopa1=a1*r+b(j):b(j)=Int(a1/25):a1=-25*b(j)+a1d=b1*r+b(j)-c(j):b1=Int(d/i):a(j)=4*q*b1+a(j)b1=d-b1*iNextjIfb(k)=0Thenk=k+1IfkMod100=0ThenText1.Text=kDoEvents'为了系统处理其他程序EndIfEndIfi=i+2LoopUntilm>pDoq=-q:a1=0:b1=0Forj=kTopa1=a1*r+b(j):b2=Int
7、(a1/25):b(j)=b2a1=-25*b2+a1:d=b2+b1*rb1=Int(d/i):a(j)=4*q*b1+a(j)b1=d-b1*iNextji=i+2Ifb(k)=0Thenk=k+1IfkMod200=0ThenText1.Text=kDoEvents'为了系统处理其他程序EndIfEndIfLoopUntilk>p'预留足够长的缓冲空间strS1=Space(p*12)n=0Dimstr1AsStringForj=pTo1Step-1g=a(j)+nn=Int(g/r)a(j)=g-r*
8、nNextjForj=1Top-1str1=a(j)X=Len(str1)str1=Left(str1,X-5)&""&Right(str1,5)X=Len(str1)IfX<11ThenMid(strS1,j*12,11)=(Right(Str3,11-X)&str1)'MID不用重新分配内存空间,速度快ElseMid(strS1,j*12,11)=str1EndIfNextjstrS1="π=3