vb代碼5費(fèi)下載_第1頁
vb代碼5費(fèi)下載_第2頁
vb代碼5費(fèi)下載_第3頁
vb代碼5費(fèi)下載_第4頁
vb代碼5費(fèi)下載_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、11!+2!+3!+Private Sub Command1_Click()Dim n%, i%, s%, m%n =val( InputBox("請輸入一個(gè)正整數(shù)") '編寫程序計(jì)算m = 1For i = 1 To nm = m * is = s + mNext iLabel1.Caption = sEnd Sub2隨機(jī)產(chǎn)生10個(gè)數(shù),最大和最小,對調(diào),藍(lán)色標(biāo)記Private Sub Command1_Click()Dim a(1 To 10) As Integer, i%, min%, max%, t%Print "產(chǎn)生的10個(gè)數(shù)是:"For

2、 i = 1 To 10a(i) = Int(Rnd * 91 + 10)Print a(i);Next imin = 1max = 1For i = 2 To 10If a(i) > a(max) Then max = iIf a(i) < a(min) Then min = iNextt = a(max)a(max) = a(min)a(min) = tPrintPrint "調(diào)換之后的數(shù):"Form1.FontSize = 16Form1.ForeColor = vbBlueFor i = 1 To 10Print a(i);Next iEnd Sub3水

3、平滾動(dòng)條,乘積的Private Sub Form_Load()HScroll1.Min = 100HScroll1.Max = 200HScroll2.Min = 100HScroll2.Max = 200End SubPrivate Sub HScroll1_Change()Label1.Caption = HSEnd SubPrivate Sub HScroll2_Change()End Sub4AaaaBbbbCcccdddd Private Sub Command1_Click() Dim i%, s As String s = "a" For i = 1 To 4

4、 Print String(4 - i, " "); String(4, s) s = Chr(Asc(s) + 1) Next i End Sub5 計(jì)算S=1+(1+2)+(1+2+3)+(1+2+3+4)+.+(1+2+3+4+5+.n) _請?jiān)诮o出的)Sum = 0For i = 1 To nj = j + iSum = Sum + jNext iText1.Text = "s=" & SumEnd Sub6通過鍵盤輸入10個(gè)數(shù) , 求這十個(gè)數(shù)的平均數(shù)?其中小于平均數(shù)的數(shù)字個(gè)數(shù)? _將小于平均數(shù)的數(shù)字個(gè)數(shù)及這十個(gè)數(shù)的平均數(shù)以紅色16號(hào)字顯

5、示在form上 Dim a(1 To 10) As IntegerFor i = 1 To 10 a(i) = Val(InputBox("請輸入第" & i & "個(gè)數(shù)")Next iPrint "輸入的十個(gè)數(shù)為:"For i = 1 To 10Print a(i);Next iFor i = 1 To 10Sum = Sum + a(i)Next iaver = Sum / 10PrintForm1.FontSize = 16Form1.ForeColor = vbRedPrint "十個(gè)數(shù)的平

6、均數(shù)為:" averPrint "小于平均數(shù)的數(shù)為:"For i = 1 To 10If a(i) < aver ThenPrint a(i);End IfNext iEnd Sub7.'計(jì)算S=1+22+23+24.+210.請?jiān)诮o出的VB3-12.FRM文件中的Private Sub Command1_Click()中完成程序,要求程序運(yùn)行時(shí),計(jì)算結(jié)果顯示在標(biāo)簽控件Label1中。 _S=1+22+23+24.+210.=21+22+23+24.+210-1Sum = 0For i = 1 To 10Sum = Sum + 2 iNext is

7、= Sum - 1Print s;End Sub10個(gè)1100之間的數(shù)并存放在數(shù)組中,以藍(lán)色17號(hào)字顯示數(shù)組? _找到其中6的倍數(shù),并求出這些數(shù)的和,將這些6的倍數(shù)和他們的和以藍(lán)色16號(hào)字顯示在窗體中ClsDim a(1 To 10) As IntegerFor i = 1 To 10a(i) = Int(Rnd * 100 + 1)Next iForm1.ForeColor = vbBlueForm1.FontSize = 17Print "十個(gè)隨機(jī)數(shù)為:"For i = 1 To 10  Form1.Print a(i);Next iSum = 0P

8、rintForm1.ForeColor = vbBlueForm1.FontSize = 16Print "是6的倍數(shù)為:"For i = 1 To 10If a(i) Mod 6 = 0 ThenPrint a(i);Sum = Sum + a(i)End IfNext iPrintPrint "6的倍數(shù)之和為:"Print Sum;End Sub9.'S=1+(1+2)+(1+2+3)+(1+2+3+4)+.+(1+2+3+4+5+.n)n = InputBox("請輸入正整數(shù)n")Sum = 0: j = 0For i

9、= 1 To n  j = j + iSum = Sum + jNext iPrint SumEnd Sub10個(gè)1100之間的整數(shù)存放在數(shù)組中,以藍(lán)色18號(hào)字顯示窗體中 _找到其中最大小的數(shù),并將此數(shù)從數(shù)組中刪除 _將刪除以后的數(shù)組以藍(lán)色18號(hào)字顯示在窗體中Color = vbBlueForm1.FontSize = 18For i = 1 To 10 a(i) = Int(Rnd * (91) + 10)Next iFor i = 1 To 10Print a(i);Next ii = 1For j = i + 1 To 10If a(i) < a(j)

10、 Thenk = a(i)a(i) = a(j)a(j) = kEnd IfNext jPrintPrint "最大數(shù)為:"Print a(1)Print "刪除最大數(shù)重新排列為:"For i = 2 To 10Print a(i);Next i Private Sub Command1_Click()'編寫程序Dim x As Integer, y As Integer, t As Integer, r As Integerx = Val(Text1.Text)y = Val(Text2.Text)If x < y Then t = x:

11、 x = y: y = tr = x Mod yDo While (r <> 0)x = y: y = r: r = x Mod yLoopLabel4.Caption = "最大公約數(shù)=" & yEnd Sub12.12345,2468,369,48,5Private Sub Command1_Click()編寫程序打印給出的圖形Dim i As Integer, j As IntegerFor i = 1 To 5For j = 1 To 6 - iPrint i * j; Spc(1);Next jPrintNext iEnd Sub+22+222

12、+Private Sub Form_Click()Dim i As Integer, j As Long, sum As Long, n As Longn = Val(InputBox("請輸入一個(gè)整數(shù)")j = 0For i = 1 To nj = j + 2 * 10 (i - 1)sum = sum + jNext iPrint "2+22+222+." j; "=" sumEnd Sub14.1+22+333+Private Sub Form_Click()Dim i As Integer, j As Long, sum As

13、 Long, n As Long, k As Integern = Val(InputBox("請輸入一個(gè)整數(shù)")For i = 1 To nFor j = 1 To ik = k + i * 10 (j - 1)Next jsum = sum + kNext iPrint "1+22+33+." k; "=" sumEnd Sub15.12 43 6 94 8 12 165 10 15 20 25Private Sub Form_Click()Dim i As Integer, j As IntegerFor i = 1 To 5F

14、or j = 1 To iPrint i * j; Spc(2);Next jPrintNext iEnd Sub16.通過鍵盤輸入10個(gè)數(shù),找到其中大于60的數(shù),并求出這些數(shù)的和,將大于60的數(shù)和和它們的和一紅色16號(hào)字顯示在標(biāo)簽中。Private Sub Command1_Click()Dim x%, i%, sum%, s As Strings = "大于60的數(shù)"Print "10個(gè)數(shù)為"For i = 1 To 10 x = Val(InputBox("請輸入十個(gè)正整數(shù)") Print x; If x > 60 The

15、n sum = sum + x s = s & x & " " End IfNext iLabel1.ForeColor = vbRedLabel1.FontSize = 16Label1.Caption = s & "總和" & sumEnd Sub17.編寫調(diào)色板程序,當(dāng)改變3種顏色的滾動(dòng)條時(shí),相應(yīng)的label4,label5,label6顯示滾動(dòng)條的變化數(shù)值,而label7顯示調(diào)出的顏色.Private Sub B_Change()Label7.BackColor = RGB(R.Value, G.Value, B.

16、Value)End SubPrivate Sub G_Change()Label7.BackColor = RGB(R.Value, G.Value, B.Value)End SubPrivate Sub Label7_Click()End SubPrivate Sub R_Change()Label7.BackColor = RGB(R.Value, G.Value, B.Value)End Sub18.1在text1,text2,text3中分別輸入代表三角形三條邊數(shù)值 2判斷這三條邊是否能構(gòu)成一個(gè)三角形3如果能構(gòu)成三角形是一個(gè)什么樣的三角形任意三角形,等邊三角形,等腰三角形,直角三角形4

17、將結(jié)果在圖形框picture中輸出Private Sub Command1_Click()Clsa = Val(Text1.Text)b = Val(Text2.Text)c = Val(Text3.Text)If a + b > c And b + c > a And c + a > b ThenIf a = b And b = c And a = c ThenPicture1.Print "等邊三角形"ElseIf a = b And c <> a ThenPicture1.Print "等腰三角形"ElseIf c =

18、 a And b <> c ThenPicture1.Print "等腰三角形"ElseIf b = c And b <> a ThenPicture1.Print "等腰三角形"ElseIf a * a + b * b = c * c Or c * c + b * b = a * a Or a * a + c * c = b * b ThenPicture1.Print "直角三角形"ElsePicture1.Print "任意三角形"End IfElsePicture1.Print &q

19、uot;不能夠成三角形"End IfEnd Subform_load() 將兩個(gè)水平滾動(dòng)條的取值范圍設(shè)為100200之間 2hscroll1_change()將兩個(gè)水平滾動(dòng)條當(dāng)前取值的乘積顯示在label1中 3print_sub hscroll2_change() 將兩個(gè)水平滾動(dòng)條當(dāng)前取值的乘積顯示在label1中Private Sub HScroll1_Change()HScroll1.Min = 100HScroll1.Max = 200HScroll2.Min = 100HScroll2.Max = 200Dim x&, y&x = Val(HScroll1.

20、Value)y = Val(HScroll2.Value)Label1.Caption = Str(x * y)End SubPrivate Sub HScroll2_Change()HScroll1.Min = 100HScroll1.Max = 200HScroll2.Min = 100HScroll2.Max = 200Dim x&, y&x = Val(HScroll1.Value)y = Val(HScroll2.Value)Label1.Caption = Str(x * y)End Sub20. 1 222 333334444444555555555 用for循環(huán)語句編寫程序輸出Private Sub Command1_Click

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論