VB基礎(chǔ)試題課件_第1頁
VB基礎(chǔ)試題課件_第2頁
VB基礎(chǔ)試題課件_第3頁
VB基礎(chǔ)試題課件_第4頁
VB基礎(chǔ)試題課件_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、VB合作學(xué)習(xí)報(bào)告,第四組,指導(dǎo)教師:朱旭萍,1,VB基礎(chǔ)試題,組長:張建迢 組員:彭佳媛 徐彩依 李靜雯 鄔祺軻 湯敦邦,主題:順序和選擇程序設(shè)計(jì),2,VB基礎(chǔ)試題,一:滾動(dòng)字幕程序設(shè)計(jì),屏幕上一標(biāo)簽,文字內(nèi)容:祝您考試成功,該標(biāo)簽?zāi)軓淖蟮接一蛘邚挠业阶鬂L動(dòng)顯示。,3,VB基礎(chǔ)試題,4,VB基礎(chǔ)試題,Private Sub Timer1_Timer() If Label1.Left Form1.Width Then Label1.Left = Label1.Left + 100 Else Label1.Left = -Label1.Width End If End Sub,Private Su

2、b Command1_Click() If Command1.Caption = 開始 Then Timer1.Enabled = True Command1.Caption = 停止 Else Timer1.Enabled = False Command1.Caption = 開始 End If Timer1.Interval = 100 End Sub Private Sub Form_Load() Form1.Caption = 字幕滾動(dòng) Label1.Caption = 祝您考試成功! Label1.Font = 宋體 Label1.FontBold = True Label1.Fon

3、tSize = 22 Label1.ForeColor = vbRed Command1.Caption = 開始 End Sub,5,VB基礎(chǔ)試題,二:利用計(jì)時(shí)器可以按指定間隔時(shí)間對字體進(jìn)行放大。 并要求字的顏色也按指定時(shí)間間隔隨機(jī)改變,6,VB基礎(chǔ)試題,7,VB基礎(chǔ)試題,Private Sub Form_Load() Label1.Caption = 放大 Label1.Font = 宋體 Label1.FontBold = True Label1.FontSize = 20 Label1.ForeColor = vbRed End Sub Private Sub Timer1_Timer

4、() If Label1.FontSize 100 Then Label1.FontSize = Label1.FontSize + 10 Else Label1.FontSize = 20 End If Label1.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) End Sub,8,VB基礎(chǔ)試題,三:完成秒數(shù)轉(zhuǎn)換成時(shí)分秒的程序,9,VB基礎(chǔ)試題,10,VB基礎(chǔ)試題,Private Sub Command1_Click() Dim a As Long, e As Long, f As Integer, g As Integer a = Val

5、(Text1.Text) e = a 3600 f = (a Mod 3600) 60 g = a - e * 3600 - f * 60 Text2.Text = Str(e) Text3.Text = Str(f) Text4.Text = Str(g) End Sub Private Sub Command2_Click() End End Sub,11,VB基礎(chǔ)試題,4.電子倒計(jì)時(shí)器設(shè)計(jì),12,VB基礎(chǔ)試題,要求:先由用戶給定倒計(jì)時(shí)的初始分秒數(shù),然后開始倒計(jì)時(shí),當(dāng)計(jì)到0分0秒時(shí),通過消息對話框顯示“倒計(jì)時(shí)結(jié)束”。 在窗體上建立一個(gè)計(jì)時(shí)器(Timer1)、兩個(gè)標(biāo)簽、兩個(gè)文本框(Text1

6、和Text2)和一個(gè)命令按鈕(Command1) 計(jì)時(shí)器的Enabled屬性值為True, Interval屬性值為0,13,VB基礎(chǔ)試題,Dim m As Integer, s As Integer Private Sub Command1_Click() m = Val(Text1.Text) s = Val(Text2.Text) Timer1.Enabled = True End Sub Private Sub Form_Load() Timer1.Enabled = False Timer1.Interval = 1000 End Sub,Private Sub Timer1_Tim

7、er() If s 0 Then s = s - 1 Else If m 0 Then m = m - 1 s = 59 End If End If Text1.Text = Format(m, 00) Text2.Text = Format(s, 00) If s = 0 And m = 0 Then MsgBox 計(jì)時(shí)結(jié)束 Timer1.Enabled = False End If End Sub,14,VB基礎(chǔ)試題,討論五:輸入三角形的三邊長(可以用消息框也可以用文本框),求三角形的面積。要判斷輸入的三邊能否構(gòu)成三角形。,能構(gòu)成三角形時(shí)結(jié)果,15,VB基礎(chǔ)試題,方法一: Private

8、Sub Form_Click() Dim a As Integer, b As Integer, c As Integer,s As integer a = InputBox(請輸入三角形的一條邊長:) b = InputBox(請輸入三角形的第二條邊長:) c = InputBox(請輸入三角形的第三條邊長:) If a + b c And b + c a And a + c b Then d = (a + b + c) / 2 s = Sqr(d * (d - a) * (d - b) * (d - c) FontSize = 22 Print 請輸入三角形的三邊: FontSize =

9、22 Print “三邊分別為:” ; a,;b; c FontSize = 22 Print “三角形的面積是:” ; s Else Print 不能組成三角形 End If End Sub,16,VB基礎(chǔ)試題,方法二: Private Sub Form_Click() FontSize = 22 Print 請輸入三角形的三邊: Dim a As Single, b As Single, c As Single a = InputBox(請輸入三角形的第一條邊的長度, 數(shù)據(jù)輸入, 5) b = InputBox(請輸入三角形的第二條邊的長度, 數(shù)據(jù)輸入, 5) c = InputBox(請

10、輸入三角形的第三條邊的長度, 數(shù)據(jù)輸入, 5) If a = 0 Or b = 0 Or c = 0 Then m = MsgBox(輸入有誤,請重新輸入!, 48, 數(shù)據(jù)輸入出錯(cuò)) If m = 1 Then Form_Click Else End End If,Else If (a + b) c And (a + c) b And (b + c) a Then d = (a + b + c) / 2 s = Sqr(d * (d - a) * (d - b) * (d - c) FontSize = 22 Print 三邊分別為:; a; b; c FontSize = 22 Print

11、三角形的面積是:; s Else n = MsgBox(此三邊不能構(gòu)成三角形!是否重新輸入?, 49, 數(shù)據(jù)輸入出錯(cuò)) If n = 1 Then Form_Click Else End End If End If End If End Sub,17,VB基礎(chǔ)試題,六:求一元二次方程ax2+bx+c0的解,18,VB基礎(chǔ)試題,(1)分析:方程的解有以下幾種可能: 若a=0,不是二次方程 若b2 - 4ac=0,有兩個(gè)相等實(shí)根 若b2 - 4ac0,有兩個(gè)不等實(shí)根 若b2 - 4ac0,有兩個(gè)共軛復(fù)根 (2)程序框圖程序框圖 程序框圖也稱程序流程圖,它能直觀地表示程序的處理步驟, 是一種描述算法

12、的常用方法。 (3)建立應(yīng)用程序的用戶界面和設(shè)置對象屬性 (4)編寫程序代碼,19,VB基礎(chǔ)試題,20,VB基礎(chǔ)試題,Private Sub Command1_Click() Dim a As Integer, b As Integer, c As Integer, d As Integer, r As Integer, p As Single a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) If a = 0 Then Text4.Text = 不是二次方程 Text5.Text = 不是二次方程 Else d = b * b - 4 * a * c r = -b / (2 * a) If d = 0 Then Text4.Text = Str(r) Text5.Text = Str(r),Else d = b * b - 4 * a * c r = -b / (2 * a) If d = 0 Then Text4.Text = Str(r) Text5.Text = Str(r) Else If d 0 Then Text4.Text = Str(-

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論