vb實(shí)驗(yàn)答案aspan class資料_第1頁
vb實(shí)驗(yàn)答案aspan class資料_第2頁
vb實(shí)驗(yàn)答案aspan class資料_第3頁
vb實(shí)驗(yàn)答案aspan class資料_第4頁
vb實(shí)驗(yàn)答案aspan class資料_第5頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

kwsy1.2屬性設(shè)置二PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickTextBox1.Enabled=FalseEndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickTextBox1.Visible=FalseEndSubPrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickTextBox1.Enabled=TrueTextBox1.Visible=TrueEndSubEndClasskwsy2.3評選獎學(xué)金PublicClassForm1PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickTextBox1.Text=""TextBox2.Text=""TextBox3.Text=""TextBox4.Text=""TextBox1.Focus()EndSubPrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton3.ClickEndEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDima!,b!,c!,d!a=Val(TextBox1.Text)b=Val(TextBox2.Text)c=Val(TextBox3.Text)d=(a+b+c)/3If(a=100Andb=100Andc>=80)Or(a=100Andc=100Andb>=80)Or(b=100Andc=100Anda>=80)Ord>=95ThenTextBox4.Text="獲一等獎"ElseIfd>=85Anda>80Andb>=80Andc>=80ThenTextBox4.Text="獲二等獎"ElseIfd>=80ThenTextBox4.Text="獲三等獎"ElseTextBox4.Text="不獲獎學(xué)金"EndIfEndSubEndClasskwsy1.4藥物反應(yīng)PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimx!,y!x=Val(InputBox("請輸入藥物劑量","輸入框"))y=1000*x-x*xMsgBox("敏感度為"&y,,"輸出框")EndSubEndClass求一元二次方程的根ImportsSystem.MathPublicClassForm1PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickEndEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDima#,b#,c#,d!,x$,y$a=Val(TextBox1.Text)b=Val(TextBox2.Text)c=Val(TextBox3.Text)d=b*b-4*a*cIfd>0Thend=Sqrt(d)x=(-b+d)/2/ay=(-b-d)/2/aTextBox4.Text=xTextBox5.Text=yElseIfd=0Thenx=-b/2/ay=-b/a/2TextBox4.Text=xTextBox5.Text=yElsed=Math.Sqrt(-d)x=Format(-b/2/a,"0.0000")y=Format(d/2/a,"0.0000")TextBox4.Text=x&"+"&y&"i"TextBox5.Text=x&"-"&y&"i"EndIfEndSubEndClass求最大公約數(shù)和最小公倍數(shù)PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickEndEndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickDima,b,n,m,rAsLonga=Val(TextBox1.Text)b=Val(TextBox2.Text)Ifa=0Orb=0ThenInputBox("請重新輸入")EndIfIfa>bThenm=a:n=bElsen=a:m=bEndIfDor=mModnm=nn=rLoopWhile(r<>0)Label3.Text="結(jié)果為:"&vbCrLfLabel3.Text&=a&"與"&b&"的最大公約數(shù)為"&m&vbCrLfLabel3.Text&=a&"與"&b&"的最小公倍數(shù)為"&a*b/mEndSubEndClass特殊圖形顯示(二)P24PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickEndEndSubPrivateSubLabel1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesLabel1.ClickDimi!,j%Label1.Text=""Fori=1To5Label1.Text&=Space(3*(i-1))&"★"Forj=1To17-3*iLabel1.Text&="☆"NextjLabel1.Text&="★"&vbCrLfNextiLabel1.Text&=Space(3*(i-1))&"☆"&vbCrLfFori=5To1Step-1Label1.Text&=Space(3*(i-1))&"☆"Forj=1To17-3*iLabel1.Text&="★"NextjLabel1.Text&="☆"&vbCrLfNextiEndSubEndClasskysy3.1產(chǎn)量問題PublicClassForm1PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickEndEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimn%,max!,s!s=0max=0Forn=20To50s=n*(300-10*(n-20))Ifs>maxThenmax=sEndIfNextForn=20To50s=n*(300-10*(n-20))Ifs=maxThenLabel1.Text&="當(dāng)每畝地種植"&n&"棵梨樹時(shí)達(dá)到最高產(chǎn)量為"&max&"kg"&vbCrLfEndIfNextEndSubEndClasskysy3.2猴子吃桃子PublicClassForm1PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickEndEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimx!x=1Label1.Text="第7天的桃子數(shù)為:1個(gè)"&vbCrLfFori=6To1Step-1x=2*(x+1)Label1.Text&="第"&i&"天的桃子數(shù)為:"&x&"個(gè)"&vbCrLfNextiEndSubEndClasskysy3.3求自然對數(shù)ePublicClassForm1PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickEndEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimi%,r#,s#s=1r=1i=0Doi=i+1r=r*is=s+1/iLoopWhile1/r>=0.00001Label1.Text="e的值為"&Format(s,"#.######")MsgBox("e的值為"&Format(s,"#.######"),,"求e的值")EndSubEndClasskysy3.4求素?cái)?shù)PublicClassForm1PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickEndEndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimm!,i!,n!n=0Form=1To100Fori=2Tom-1IfmModi=0ThenExitForNextiIfi=mThenn=n+1Ifn=7Thenn=0Label2.Text&=vbCrLfEndIfLabel2.Text&=m&Space(1)EndIfNextmEndSubEndClasskysy3.5圖形顯示PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickEndEndSubPrivateSubLabel1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesLabel1.ClickDimi!,j%Label1.Text=""Fori=1To6Label1.Text&=Space(6-i)Forj=1To2*i-1Label1.Text&=Chr(64+i)NextjLabel1.Text&=vbCrLfNextiEndSubEndClasssy4.1運(yùn)動成績排序PublicClassForm1InheritsSystem.Windows.Forms.FormDimi%,j%,m%,temp!,t$,n%Dima$()={207,126,453,"096",339,"077",231,276,122,302}Dimb!()={14.5,14.2,15.2,15.7,14.9,15.1,14.7,13.9,13.7,14.5}PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickLabel1.Text=""Label1.Text="運(yùn)動員編號"&Space(3)&"成績(秒)"&vbCrLfDimi%m=UBound(b)n=UBound(a)Fori=0TonLabel1.Text&=a(i)&Space(7)&b(i)&vbCrLfNextEndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickLabel2.Text=""Label2.Text="名次"&Space(3)&"編號"&Space(3)&"成績(秒)"&vbCrLfDimi%,j%Fori=0To8m=iForj=i+1To9Ifb(m)>b(j)Thenm=jNextjtemp=b(m):b(m)=b(i):b(i)=tempt=a(m):a(m)=a(i):a(i)=tLabel2.Text&=i+1&Space(6)&a(i)&Space(6)&b(i)&vbCrLfNextiLabel2.Text&=i+1&Space(6)&a(i)&Space(6)&b(i)&vbCrLfEndSubEndClasssy4.2矩陣求解PublicClassForm1InheritsSystem.Windows.Forms.FormDimi%,j%,a%(5,5),s%,m%,n%,k%PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickRandomize()Dimi%,j%Label1.Text=""Fori=0To4Forj=0To4a(i,j)=Int(Rnd()*99+1)Label1.Text&=a(i,j)&Space(8-Len(a(i,j)))NextLabel1.Text&=vbCrLf&vbCrLfNextEndSubPrivateSubButton2_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesButton2.ClickDimi%,j%Label2.Text=""a(i,j)=Len(Label1.Text)Fori=0To4s+=a(i,i)NextLabel2.Text="主對角線元素之和是:"Label2.Text&=sEndSubPrivateSubButton3_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesButton3.ClickDimi%,j%Label3.Text=""a(i,j)=Len(Label1.Text)a(m,n)=0Fori=0To4Forj=0To4Ifa(m,n)<a(i,j)Thenm=i:n=jNextNextLabel3.Text="最大元素是:"Label3.Text&="第"&m+1&"行,第"&n+1&"列的"&a(m,n)EndSubPrivateSubButton4_Click(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesButton4.ClickDimi%,j%a(i,j)=Len(Label1.Text)k=InputBox("請輸入您要查找的元素:")m=5:n=5Fori=0To4Forj=0To4Ifk=a(i,j)Thenm=i:n=j:ExitForNextNextIfm=5Andn=5ThenMsgBox("您要查找的元素不存在")ElseMsgBox("您要查找的元素在第"&m+1&"行,第"&n+1&"列")EndIfEndSubPrivateSubButton5_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton5.ClickEndEndSubEndClasssy4.3楊輝三角形PublicClassForm1Dima%(1,1),i%,j%,n%PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDima%(1,1),i%,j%,n%n=Val(TextBox1.Text)ReDima%(n,n)Fori=1Tona(i,1)=1a(i,i)=1NextiFori=3TonForj=1Toia(i,j)=a(i-1,j-1)+a(i-1,j)NextNextLabel1.Text=""Fori=1TonForj=1ToiLabel1.Text&=Space(6-Len(Str(a(i,j))))&a(i,j)NextLabel1.Text&=vbCrLfNextEndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickDima%(1,1),i%,j%,n%n=Val(TextBox1.Text)ReDima%(n,n)Fori=1Tona(i,1)=1a(i,i)=1NextiFori=3TonForj=1Toia(i,j)=a(i-1,j-1)+a(i-1,j)NextNextFori=1TonForj=1ToiLabel2.Text&=Space(6-Len(a(i,j)))&a(i,j)NextLabel2.Text&=vbCrLfNextLabel2.Text=""Fori=1TonLabel2.Text&=Space(2*n-2*i)Forj=1ToiLabel2.Text&=Space(6-Len(Str(a(i,j))))&a(i,j)NextLabel2.Text&=vbCrLfNextEndSubEndClasssy4.4猴子選大王PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDima()AsInt16Dimm%,n%,i%,j%,t%m=Int(TextBox1.Text)n=Int(TextBox2.Text)ReDima(m)t=mi=1DoWhilet<>1Ifa(i)<>-1Thenj=j+1Ifj=nThena(i)=-1:t=t-1:j=0Elsea(i)=jEndIfEndIfi=i+1Ifi=m+1Theni=1LoopFori=1TomIfa(i)<>-1ThenMsgBox("猴王是第"&i&"只猴子!")NextEndSubEndClass心形圖的顯示PublicClassForm1PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickEndEndSubPrivateSubLabel1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesLabel1.ClickDimi%DimsAsString="☆"Label1.Text=""Fori=1To4Label1.Text&=Space(4-i)&s&Space(2*(i-1))&s&Space(4-i)&Space(4-i)&s&Space(2*(i-1))&s&Space(4-i)&vbCrLfNextFori=1To9Label1.Text&=Space(i-1)&s&Space(9-i)&Space(9-i)&s&vbCrLfNextLabel1.Text&=Space(9)&sEndSubEndClasskysy4.3N人開關(guān)燈問題PrivateSubLabel1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesLabel1.ClickLabel1.Text=""Label1.Text="N盞燈排成一排,從1到N依次編號。有N個(gè)人"&vbCrLfLabel1.Text&="也從1到N依次編號。第一個(gè)人將燈全部關(guān)閉"&vbCrLfLabel1.Text&="第二個(gè)人將凡是2和2的倍數(shù)的燈全部打開,"&vbCrLfLabel1.Text&="第三個(gè)人將凡是3和3的倍數(shù)的燈作相反處理,"&vbCrLfLabel1.Text&="以后的人都跟3號一樣,問第N個(gè)人操作之后,"&vbCrLfLabel1.Text&="哪幾盞燈是點(diǎn)亮的?"EndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimi%,j%,n%,m%Dima%()n=Val(TextBox1.Text)ReDima%(n)Forj=1Tona(j)=1NextFori=1TonForj=1TonIfjModi=0ThenIfa(j)=0Thena(j)=1Elsea(j)=0EndIfEndIfNextNextLabel3.Text=""Label3.Text="點(diǎn)亮的燈為:"Forj=1TonIfa(j)=1ThenLabel3.Text&=j&","m=m+1EndIfNextLabel3.Text&=vbCrLf&"點(diǎn)亮的燈數(shù)為:"&mEndSubEndClasskysy4.4分魚問題PublicClassForm1PrivateSubLabel1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesLabel1.ClickLabel1.Text="A,B,C,D,E合伙夜間捕魚,凌晨時(shí)就疲憊不堪,各自在河邊的"&vbCrLfLabel1.Text&="樹叢中找地方睡著了。日上三竿,A第一個(gè)醒來,他將魚平均"&vbCrLfLabel1.Text&="分為五份,把多余的一條扔回湖中,拿自己的一份回家了。B"&vbCrLfLabel1.Text&="第二個(gè)醒來,也將魚平分為五份,把多余的一條扔回湖中,只"&vbCrLfLabel1.Text&="拿走自己的一份,接著C,D,E依次醒來,也按同樣的方法分魚,"&vbCrLfLabel1.Text&="問每個(gè)人醒來后看到的魚數(shù)至少分別為多少?"EndSubPrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimi%,j%,f%(5)f(5)=1j=0DoWhilej<>4f(5)+=5Fori=5To2Step-1Iff(i)Mod4=0Thenf(i-1)=f(i)/4*5+1j=j+1Elsej=0:ExitForEndIfNextLoopLabel2.Text=""Label2.Text="他們看到的魚至少分別為:"&vbCrLfFori=1To5Label2.Text&=Chr(64+i)&":"&f(i)&"條"&vbCrLfNextEndSubEndClassKysy4.1模擬選舉PublicClassForm1Dima%,b%,c%,d%,f%,i%,j$PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Clicka=Val(TextBox1.Text)Ifa=1Thenb=b+1ElseIfa=2Thenc=c+1ElseIfa=3Thend=d+1ElseIfa=4Thenf=f+1EndIfTextBox1.Text=""TextBox1.Focus()EndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickLabel1.Text&=vbCrLf&"張三"&bLabel1.Text&=vbCrLf&"李四"&cLabel1.Text&=vbCrLf&"王五"&dLabel1.Text&=vbCrLf&"趙六"&f&vbCrLfDimg()AsInteger={b,c,d,f}Dimh()AsString={"張三","李四","王五","趙六"}i=g(0):j=h(0)Fork=0To3Ifi<g(k)Theni=g(k):j=h(k)EndIfNextLabel1.Text&="************"&j&"當(dāng)選!************"EndSubEndClassSy5.1六合彩開獎系統(tǒng)PublicClassForm1Dima%(5),n$,m$PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.Clickn=Val(TextBox1.Text)Timer1.Enabled=TrueEndSubPrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton2.ClickTimer1.Enabled=Falsem=a(0)&a(1)&a(2)&a(3)&a(4)&a(5)Ifm=nThenMsgBox("恭喜中獎")ElseMsgBox("本期中獎號碼為:"&m&vbCrLf&"您的彩票號碼為:"&n&"謝謝您的支持!")EndIfEndSubPrivateSubTimer1_Tick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Hand

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論